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(
|
$self->attr(
|
||||||
mark_for_deletion_query => sub {
|
mark_for_deletion_query => sub {
|
||||||
my ($self) = @_;
|
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(
|
$self->attr(
|
||||||
get_stationid_by_ds100_query => sub {
|
get_stationid_by_ds100_query => sub {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
@ -1019,11 +995,14 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
|
||||||
'get_user_token' => sub {
|
'get_user_token' => sub {
|
||||||
my ( $self, $uid ) = @_;
|
my ( $self, $uid ) = @_;
|
||||||
|
|
||||||
my $query = $self->app->get_token_query;
|
my $res = $self->pg->db->select(
|
||||||
$query->execute($uid);
|
'users',
|
||||||
my $rows = $query->fetchall_arrayref;
|
[ 'name', 'status', 'token' ],
|
||||||
if ( @{$rows} ) {
|
{ id => $uid }
|
||||||
return @{ $rows->[0] };
|
);
|
||||||
|
|
||||||
|
if ( my $ret = $res->array ) {
|
||||||
|
return @{$ret};
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ sub verify {
|
||||||
$self->render( 'register', invalid => 'token' );
|
$self->render( 'register', invalid => 'token' );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$self->app->set_status_query->execute( 1, $id );
|
$self->app->pg->db->update( 'users', { status => 1 }, { id => $id } );
|
||||||
$self->render( 'login', from => 'verification' );
|
$self->render( 'login', from => 'verification' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue