Compare commits
No commits in common. "569aa1c95b8aae9576f71599081546ddedb7d982" and "77365cc0c3ed953b8f948d2360bdcc1d6ff30b1b" have entirely different histories.
569aa1c95b
...
77365cc0c3
|
@ -69,8 +69,7 @@ sub startup {
|
||||||
|
|
||||||
# session helpers
|
# session helpers
|
||||||
## create session
|
## create session
|
||||||
$app->helper(
|
$app->helper(session_create => sub {
|
||||||
session_create => sub {
|
|
||||||
my $app = shift;
|
my $app = shift;
|
||||||
|
|
||||||
my $_session_key = seasoning(16);
|
my $_session_key = seasoning(16);
|
||||||
|
@ -89,26 +88,23 @@ sub startup {
|
||||||
$app->session(user_id => $_[0] );
|
$app->session(user_id => $_[0] );
|
||||||
$app->session(session_key => $_session_key);
|
$app->session(session_key => $_session_key);
|
||||||
$app->session(expiration => 604800 );
|
$app->session(expiration => 604800 );
|
||||||
}
|
});
|
||||||
);
|
|
||||||
## destroy session
|
## destroy session
|
||||||
$app->helper(
|
$app->helper(session_destroy => sub {
|
||||||
session_destroy => sub {
|
|
||||||
my $app = shift;
|
my $app = shift;
|
||||||
|
|
||||||
my $_session_key = $app->session('session_key');
|
my $_session_key = $app->session('session_key');
|
||||||
|
|
||||||
# destroy entry for this session in the database
|
# destroy entry for this session in the database
|
||||||
$app->schema->resultset('Session')
|
$app->schema->resultset('Session')
|
||||||
->search({ session_key => $_session_key })->delete;
|
->search({ session_key => $_session_key })
|
||||||
|
->delete;
|
||||||
|
|
||||||
# now nuke the actual session cookie
|
# now nuke the actual session cookie
|
||||||
$app->session(expires => 1);
|
$app->session(expires => 1);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
## verify session
|
## verify session
|
||||||
$app->helper(
|
$app->helper(session_verify => sub {
|
||||||
session_verify => sub {
|
|
||||||
my $app = shift;
|
my $app = shift;
|
||||||
|
|
||||||
my $_validity = 1;
|
my $_validity = 1;
|
||||||
|
@ -122,21 +118,21 @@ sub startup {
|
||||||
if ($_is_auth) {
|
if ($_is_auth) {
|
||||||
try {
|
try {
|
||||||
# check to see if session with this id is present in db
|
# check to see if session with this id is present in db
|
||||||
($app->schema->resultset('Session')
|
($app->schema->resultset('Session')->search
|
||||||
->search({ 'session_key' => $_session_key })
|
({ 'session_key' => $_session_key })
|
||||||
->get_column('session_key')->first)
|
->get_column('session_key')->first)
|
||||||
or die;
|
or die;
|
||||||
|
|
||||||
# check to see if the current session key's user id matches
|
# check to see if the current session key's user id matches
|
||||||
# that of the user id in the database
|
# that of the user id in the database
|
||||||
$_user_id == ($app->schema->resultset('Session')
|
$_user_id == ($app->schema->resultset('Session')->
|
||||||
->session_uid($_session_key))
|
session_uid($_session_key))
|
||||||
or die;
|
or die;
|
||||||
|
|
||||||
# check if session is still within valid time as recorded in
|
# check if session is still within valid time as recorded in
|
||||||
# the db
|
# the db
|
||||||
time < ($app->schema->resultset('Session')
|
time < ($app->schema->resultset('Session')->
|
||||||
->session_expiry($_session_key))
|
session_expiry($_session_key))
|
||||||
or die;
|
or die;
|
||||||
} catch ($_catch_error) {
|
} catch ($_catch_error) {
|
||||||
$_validity = undef;
|
$_validity = undef;
|
||||||
|
@ -147,8 +143,7 @@ sub startup {
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_validity;
|
return $_validity;
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
# router
|
# router
|
||||||
my $r = $app->routes;
|
my $r = $app->routes;
|
||||||
|
|
|
@ -62,8 +62,7 @@ sub login_do {
|
||||||
} catch ($catch_error) { # redirect to login page on fail
|
} catch ($catch_error) { # redirect to login page on fail
|
||||||
print $catch_error;
|
print $catch_error;
|
||||||
$c->flash(
|
$c->flash(
|
||||||
error =>
|
error => 'Your username and password were correct, but a server
|
||||||
'Your username and password were correct, but a server
|
|
||||||
error prevented you from logging in. This has been logged
|
error prevented you from logging in. This has been logged
|
||||||
so the administrator can fix it.'
|
so the administrator can fix it.'
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,14 +16,15 @@ sub thread_compose {
|
||||||
my $subf_cat =
|
my $subf_cat =
|
||||||
$c->schema->resultset('Subforums')->cat_from_id($subf_id);
|
$c->schema->resultset('Subforums')->cat_from_id($subf_id);
|
||||||
my $cat_title =
|
my $cat_title =
|
||||||
$c->schema->resultset('Categories')->title_from_id($subf_cat);
|
$c->schema->resultset('Categories')
|
||||||
|
->title_from_id($subf_cat);
|
||||||
|
|
||||||
$c->render(
|
$c->render(
|
||||||
template => 'thread_compose',
|
template => 'thread_compose',
|
||||||
subf_id => $subf_id,
|
subf_id => $subf_id,
|
||||||
cat_title => $cat_title,
|
cat_title => $cat_title,
|
||||||
subf_title =>
|
subf_title => $c->schema->resultset('Subforums')
|
||||||
$c->schema->resultset('Subforums')->title_from_id($subf_id),
|
->title_from_id($subf_id),
|
||||||
error => $c->flash('error'),
|
error => $c->flash('error'),
|
||||||
message => $c->flash('message')
|
message => $c->flash('message')
|
||||||
)
|
)
|
||||||
|
|
|
@ -53,9 +53,8 @@ sub register_do {
|
||||||
## search for input username and email in database
|
## search for input username and email in database
|
||||||
$user_check = $c->schema->resultset('Users')
|
$user_check = $c->schema->resultset('Users')
|
||||||
->search({ username => $username })->single;
|
->search({ username => $username })->single;
|
||||||
$email_check =
|
$email_check = $c->schema->resultset('Users')
|
||||||
$c->schema->resultset('Users')->search({ email => $email })
|
->search({ email => $email })->single;
|
||||||
->single;
|
|
||||||
|
|
||||||
# TODO: compress this into something less redundant
|
# TODO: compress this into something less redundant
|
||||||
($user_check && $email_check) eq undef
|
($user_check && $email_check) eq undef
|
||||||
|
|
|
@ -16,7 +16,8 @@ sub subf_view {
|
||||||
my $subf_cat =
|
my $subf_cat =
|
||||||
$c->schema->resultset('Subforums')->cat_from_id($subf_id);
|
$c->schema->resultset('Subforums')->cat_from_id($subf_id);
|
||||||
my $cat_title =
|
my $cat_title =
|
||||||
$c->schema->resultset('Categories')->title_from_id($subf_cat);
|
$c->schema->resultset('Categories')
|
||||||
|
->title_from_id($subf_cat);
|
||||||
|
|
||||||
my @thread_list =
|
my @thread_list =
|
||||||
$c->schema->resultset('Threads')->fetch_by_subf($subf_id);
|
$c->schema->resultset('Threads')->fetch_by_subf($subf_id);
|
||||||
|
@ -25,8 +26,8 @@ sub subf_view {
|
||||||
template => 'subf',
|
template => 'subf',
|
||||||
subf_id => $subf_id,
|
subf_id => $subf_id,
|
||||||
cat_title => $cat_title,
|
cat_title => $cat_title,
|
||||||
subf_title =>
|
subf_title => $c->schema->resultset('Subforums')
|
||||||
$c->schema->resultset('Subforums')->title_from_id($subf_id),
|
->title_from_id($subf_id),
|
||||||
thread_list => \@thread_list
|
thread_list => \@thread_list
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,8 @@ use Tree::Simple;
|
||||||
|
|
||||||
sub list_full {
|
sub list_full {
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
|
|
||||||
# fetch a list of all categories
|
# fetch a list of all categories
|
||||||
my @_all_cat =
|
my @_all_cat = $c->{app}->schema->resultset('Categories')->fetch_all;
|
||||||
$c->{app}->schema->resultset('Categories')->fetch_all;
|
|
||||||
|
|
||||||
# create a Tree::Simple object that will contain the list
|
# create a Tree::Simple object that will contain the list
|
||||||
# of categories and the subforums that belong to them
|
# of categories and the subforums that belong to them
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
id="post-content"
|
id="post-content"
|
||||||
name="post-content"
|
name="post-content"
|
||||||
cols="50" rows="5"
|
cols="50" rows="5"
|
||||||
placeholder="post content"></textarea>
|
placeholder="post content">
|
||||||
<br /><br />
|
</textarea><br /><br />
|
||||||
<input type="submit" value="post!" />
|
<input type="submit" value="post!" />
|
||||||
</form>
|
</form>
|
Loading…
Reference in New Issue