Make this variable stuff more consistent, not sure why I did this

This commit is contained in:
swagg boi 2023-06-04 13:14:22 -04:00
parent 8fb64fde64
commit ee5385290a
3 changed files with 24 additions and 40 deletions

View file

@ -44,17 +44,13 @@ sub login($self) {
$self->stash(status => 400) $self->stash(status => 400)
} }
else { else {
my ($email, $password); my $email = $self->param('email' );
my $password = $self->param('password');
$email = $self->param('email' );
$password = $self->param('password');
if ($self->moderator->check($email, $password)) { if ($self->moderator->check($email, $password)) {
my ($mod_id, $mod_name, $admin_status); my $mod_id = $self->moderator->get_id($email);
my $mod_name = $self->moderator->get_name($mod_id);
$mod_id = $self->moderator->get_id($email); my $admin_status = $self->moderator->admin_status($mod_id);
$mod_name = $self->moderator->get_name($mod_id);
$admin_status = $self->moderator->admin_status($mod_id);
$self->session( $self->session(
mod_id => $mod_id, mod_id => $mod_id,
@ -162,11 +158,9 @@ sub create($self) {
$self->stash(status => 400) $self->stash(status => 400)
} }
else { else {
my ($name, $email, $password); my $name = $self->param('name' );
my $email = $self->param('email' );
$name = $self->param('name' ); my $password = $self->param('password');
$email = $self->param('email' );
$password = $self->param('password');
$self->moderator->create($name, $email, $password); $self->moderator->create($name, $email, $password);
$self->stash(info => "Created moderator account for $name 🧑‍🏭"); $self->stash(info => "Created moderator account for $name 🧑‍🏭");
@ -189,10 +183,8 @@ sub admin_reset($self) {
$self->stash(status => 400) $self->stash(status => 400)
} }
else { else {
my ($email, $password); my $email = $self->param('email' );
my $password = $self->param('password');
$email = $self->param('email' );
$password = $self->param('password');
$self->moderator->admin_reset($email, $password); $self->moderator->admin_reset($email, $password);
$self->stash(info => "Reset password for $email 🔐"); $self->stash(info => "Reset password for $email 🔐");
@ -214,10 +206,8 @@ sub mod_reset($self) {
$self->stash(status => 400) $self->stash(status => 400)
} }
else { else {
my ($password, $mod_id); my $password = $self->param('password');
my $mod_id = $self->session->{'mod_id'};
$password = $self->param('password');
$mod_id = $self->session->{'mod_id'};
$self->moderator->mod_reset($mod_id, $password); $self->moderator->mod_reset($mod_id, $password);
$self->flash(info => "Password has been reset 🔐"); $self->flash(info => "Password has been reset 🔐");

View file

@ -20,8 +20,6 @@ sub create($self) {
$v = $self->validation if $self->req->method eq 'POST'; $v = $self->validation if $self->req->method eq 'POST';
if ($v && $v->has_data) { if ($v && $v->has_data) {
my ($remark_author, $remark_body, $bump_thread);
$v->required('author')->size(1, 63); $v->required('author')->size(1, 63);
$v->required('body' )->size(2, 4000); $v->required('body' )->size(2, 4000);
$v->optional('bump' ); $v->optional('bump' );
@ -30,9 +28,9 @@ sub create($self) {
$self->stash(status => 400) $self->stash(status => 400)
} }
else { else {
$remark_author = $v->param('author'); my $remark_author = $v->param('author');
$remark_body = $v->param('body' ); my $remark_body = $v->param('body' );
$bump_thread = $v->param('bump' ); my $bump_thread = $v->param('bump' );
$self->remark->create( $self->remark->create(
$thread_id, $thread_id,

View file

@ -10,8 +10,6 @@ sub create($self) {
$v = $self->validation if $self->req->method eq 'POST'; $v = $self->validation if $self->req->method eq 'POST';
if ($v && $v->has_data) { if ($v && $v->has_data) {
my ($thread_author, $thread_title, $thread_body);
$v->required('author')->size(1, 63); $v->required('author')->size(1, 63);
$v->required('title' )->size(1, 127); $v->required('title' )->size(1, 127);
$v->required('body' )->size(2, 4000); $v->required('body' )->size(2, 4000);
@ -20,9 +18,9 @@ sub create($self) {
$self->stash(status => 400) $self->stash(status => 400)
} }
else { else {
$thread_author = $v->param('author'); my $thread_author = $v->param('author');
$thread_title = $v->param('title' ); my $thread_title = $v->param('title' );
$thread_body = $v->param('body' ); my $thread_body = $v->param('body' );
my $new_thread_id = $self->thread->create( my $new_thread_id = $self->thread->create(
$thread_author, $thread_author,
@ -42,14 +40,12 @@ sub create($self) {
} }
sub by_id($self) { sub by_id($self) {
my ($thread_id, $thread, $base_path, $this_page, $last_page, $remarks); my $thread_id = $self->param('thread_id');
my $thread = $self->thread->by_id($thread_id);
$thread_id = $self->param('thread_id'); my $base_path = $self->match->path_for(thread_page => undef)->{'path'};
$thread = $self->thread->by_id($thread_id); my $this_page = $self->param('thread_page');
$base_path = $self->match->path_for(thread_page => undef)->{'path'}; my $last_page = $self->remark->last_page_for($thread_id);
$this_page = $self->param('thread_page'); my $remarks = $self->remark->by_page_for($thread_id, $this_page);
$last_page = $self->remark->last_page_for($thread_id);
$remarks = $self->remark->by_page_for($thread_id, $this_page);
$self->stash( $self->stash(
thread => $thread, thread => $thread,