Compare commits
No commits in common. "07977292fe5c80a677d4fcca98c389ed5b252f99" and "e12849508e61a370d4258a0069fb70728a2a0e04" have entirely different histories.
07977292fe
...
e12849508e
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"kraih.mojolicious",
|
|
||||||
"aaron-bond.better-comments"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -16,54 +16,5 @@
|
||||||
"subf",
|
"subf",
|
||||||
"subforum",
|
"subforum",
|
||||||
"subforums"
|
"subforums"
|
||||||
],
|
|
||||||
"better-comments.highlightPlainText": true,
|
|
||||||
"better-comments.tags": [
|
|
||||||
|
|
||||||
{
|
|
||||||
"tag": "!",
|
|
||||||
"color": "#FF2D00",
|
|
||||||
"strikethrough": false,
|
|
||||||
"underline": false,
|
|
||||||
"backgroundColor": "transparent",
|
|
||||||
"bold": false,
|
|
||||||
"italic": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "?",
|
|
||||||
"color": "#3498DB",
|
|
||||||
"strikethrough": false,
|
|
||||||
"underline": false,
|
|
||||||
"backgroundColor": "transparent",
|
|
||||||
"bold": false,
|
|
||||||
"italic": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "//",
|
|
||||||
"color": "#474747",
|
|
||||||
"strikethrough": true,
|
|
||||||
"underline": false,
|
|
||||||
"backgroundColor": "transparent",
|
|
||||||
"bold": false,
|
|
||||||
"italic": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "todo",
|
|
||||||
"color": "#FF8C00",
|
|
||||||
"strikethrough": false,
|
|
||||||
"underline": false,
|
|
||||||
"backgroundColor": "transparent",
|
|
||||||
"bold": false,
|
|
||||||
"italic": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "*",
|
|
||||||
"color": "#98C379",
|
|
||||||
"strikethrough": false,
|
|
||||||
"underline": false,
|
|
||||||
"backgroundColor": "transparent",
|
|
||||||
"bold": false,
|
|
||||||
"italic": false
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
--
|
--
|
||||||
-- File generated with SQLiteStudio v3.4.4 on Sun. May 7 22:15:23 2023
|
-- File generated with SQLiteStudio v3.4.4 on Sun. May 7 00:02:05 2023
|
||||||
--
|
--
|
||||||
-- Text encoding used: UTF-8
|
-- Text encoding used: UTF-8
|
||||||
--
|
--
|
||||||
|
@ -48,6 +48,7 @@ DROP TABLE IF EXISTS sessions;
|
||||||
CREATE TABLE IF NOT EXISTS sessions (
|
CREATE TABLE IF NOT EXISTS sessions (
|
||||||
user_id INTEGER PRIMARY KEY
|
user_id INTEGER PRIMARY KEY
|
||||||
REFERENCES users (user_id)
|
REFERENCES users (user_id)
|
||||||
|
UNIQUE
|
||||||
NOT NULL,
|
NOT NULL,
|
||||||
session_key TEXT NOT NULL
|
session_key TEXT NOT NULL
|
||||||
UNIQUE,
|
UNIQUE,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package CharmBoard;
|
package CharmBoard;
|
||||||
|
use experimental 'smartmatch';
|
||||||
use Mojo::Base 'Mojolicious', -signatures;
|
use Mojo::Base 'Mojolicious', -signatures;
|
||||||
use CharmBoard::Schema;
|
use CharmBoard::Schema;
|
||||||
|
|
||||||
|
|
|
@ -76,42 +76,48 @@ sub login_do ($app) {
|
||||||
my $username = $app->param('username');
|
my $username = $app->param('username');
|
||||||
my $password = $app->pepper . ':' . $app->param('password');
|
my $password = $app->pepper . ':' . $app->param('password');
|
||||||
|
|
||||||
try {
|
my $userInfoCheck = $app->schema->resultset('Users')->search({username => $username});
|
||||||
# check to see if user by entered username exists
|
|
||||||
my $userInfo = $app->schema->resultset('Users')->search({username => $username});
|
|
||||||
$userInfo or die;
|
|
||||||
|
|
||||||
# now check password validity
|
if ($userInfoCheck) {
|
||||||
my $passCheck = passchk($userInfo->get_column('salt')->first,
|
my $passCheckStatus = passchk($userInfoCheck->get_column('salt')->first,
|
||||||
$userInfo->get_column('password')->first, $password);
|
$userInfoCheck->get_column('password')->first, $password);
|
||||||
$passCheck or die;
|
|
||||||
|
|
||||||
# get user ID for session creation
|
if ($passCheckStatus) {
|
||||||
my $userID = $userInfo->get_column('user_id')->first;
|
my $userID = $userInfoCheck->get_column('user_id')->first;
|
||||||
|
|
||||||
# gen session key and set expiry time
|
# delete old session from DB if exists
|
||||||
my $sessionKey = seasoning(16);
|
if ($app->schema->resultset('Session')->search({user_id => $userID})) {
|
||||||
my $sessionExpiry = time + 604800;
|
$app->schema->resultset('Session')->search({user_id => $userID})->delete; };
|
||||||
|
|
||||||
# add session to database
|
# gen session key and set expiry time
|
||||||
$app->schema->resultset('Session')->create({
|
my $sessionKey = seasoning(16);
|
||||||
|
my $sessionExpiry = time + 604800;
|
||||||
|
|
||||||
|
# add session to database
|
||||||
|
$app->schema->resultset('Session')->create({
|
||||||
user_id => $userID,
|
user_id => $userID,
|
||||||
session_key => $sessionKey,
|
session_key => $sessionKey,
|
||||||
session_expiry => $sessionExpiry,
|
session_expiry => $sessionExpiry,
|
||||||
is_ip_bound => 0,
|
is_ip_bound => 0,
|
||||||
bound_ip => undef });
|
bound_ip => undef });
|
||||||
|
|
||||||
# now create session cookie for user
|
# now create session cookie for user
|
||||||
$app->session(is_auth => 1);
|
$app->session(is_auth => 1);
|
||||||
$app->session(user_id => $userID);
|
$app->session(user_id => $userID);
|
||||||
$app->session(session_key => $sessionKey);
|
$app->session(session_key => $sessionKey);
|
||||||
$app->session(expires => $sessionExpiry);
|
$app->session(expires => $sessionExpiry);
|
||||||
|
|
||||||
# redirect to index upon success
|
# redirect to index
|
||||||
$app->redirect_to('/')}
|
$app->redirect_to('/')}
|
||||||
catch ($error) { # redir to login page on fail
|
|
||||||
print $error;
|
else {
|
||||||
$app->flash(error => 'Username or password incorrect.');
|
$app->flash(error => 'Password incorrect');
|
||||||
$app->redirect_to('login')}};
|
$app->redirect_to('login')}}
|
||||||
|
|
||||||
|
else {
|
||||||
|
$app->flash(error => 'User ' . $username . ' does not exist.');
|
||||||
|
$app->redirect_to('login')};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
|
@ -13,7 +13,7 @@ __PACKAGE__->add_columns(
|
||||||
is_nullable => 0, },
|
is_nullable => 0, },
|
||||||
thread_id => {
|
thread_id => {
|
||||||
data_type => 'integer',
|
data_type => 'integer',
|
||||||
is_auto_increment => 0,
|
is_auto_increment => 1,
|
||||||
is_nullable => 0, },
|
is_nullable => 0, },
|
||||||
post_date => {
|
post_date => {
|
||||||
data_type => 'integer',
|
data_type => 'integer',
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
use experimental 'smartmatch';
|
||||||
|
|
||||||
use Mojo::File qw(curfile);
|
use Mojo::File qw(curfile);
|
||||||
use lib curfile->dirname->sibling('lib')->to_string;
|
use lib curfile->dirname->sibling('lib')->to_string;
|
||||||
|
|
Loading…
Reference in New Issue