refactor set_status_query and get_token_query
This commit is contained in:
parent
f7db1c6a26
commit
24d0943cdc
2 changed files with 9 additions and 30 deletions
|
@ -208,17 +208,6 @@ sub startup {
|
|||
);
|
||||
}
|
||||
);
|
||||
$self->attr(
|
||||
set_status_query => sub {
|
||||
my ($self) = @_;
|
||||
|
||||
return $self->app->dbh->prepare(
|
||||
qq{
|
||||
update users set status = ? where id = ?;
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
$self->attr(
|
||||
mark_for_deletion_query => sub {
|
||||
my ($self) = @_;
|
||||
|
@ -447,19 +436,6 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
|
|||
);
|
||||
}
|
||||
);
|
||||
$self->attr(
|
||||
get_token_query => sub {
|
||||
my ($self) = @_;
|
||||
|
||||
return $self->app->dbh->prepare(
|
||||
qq{
|
||||
select
|
||||
name, status, token
|
||||
from users where id = ?
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
$self->attr(
|
||||
get_stationid_by_ds100_query => sub {
|
||||
my ($self) = @_;
|
||||
|
@ -1019,11 +995,14 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
|
|||
'get_user_token' => sub {
|
||||
my ( $self, $uid ) = @_;
|
||||
|
||||
my $query = $self->app->get_token_query;
|
||||
$query->execute($uid);
|
||||
my $rows = $query->fetchall_arrayref;
|
||||
if ( @{$rows} ) {
|
||||
return @{ $rows->[0] };
|
||||
my $res = $self->pg->db->select(
|
||||
'users',
|
||||
[ 'name', 'status', 'token' ],
|
||||
{ id => $uid }
|
||||
);
|
||||
|
||||
if ( my $ret = $res->array ) {
|
||||
return @{$ret};
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ sub verify {
|
|||
$self->render( 'register', invalid => 'token' );
|
||||
return;
|
||||
}
|
||||
$self->app->set_status_query->execute( 1, $id );
|
||||
$self->app->pg->db->update( 'users', { status => 1 }, { id => $id } );
|
||||
$self->render( 'login', from => 'verification' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue