Refactored AccountToken table
This commit is contained in:
parent
f69b06bda2
commit
dd7862d93d
10 changed files with 16 additions and 90 deletions
|
@ -58,7 +58,7 @@ sub post_register{
|
|||
$validation->input( $json );
|
||||
|
||||
my $token_rs = $c->schema->resultset('AccountToken')->search_rs({used => 0});
|
||||
$validation->required('token')->in_resultset('accounttokenname', $token_rs);
|
||||
$validation->required('token')->in_resultset('name', $token_rs);
|
||||
|
||||
my $customer_rs = $c->schema->resultset('Customer');
|
||||
$validation->required('username')->like(qr/^[A-Za-z0-9]+$/)->not_in_resultset('username', $customer_rs);
|
||||
|
@ -106,7 +106,7 @@ sub post_register{
|
|||
|
||||
$c->schema->txn_do( sub {
|
||||
$c->schema->resultset('AccountToken')->find({
|
||||
accounttokenname => $validation->param('token'),
|
||||
name => $validation->param('token'),
|
||||
used => 0,
|
||||
})->update({ used => 1 });
|
||||
$c->schema->resultset('User')->create({
|
||||
|
@ -126,7 +126,7 @@ sub post_register{
|
|||
|
||||
$c->schema->txn_do( sub {
|
||||
$c->schema->resultset('AccountToken')->find({
|
||||
accounttokenname => $validation->param('token'),
|
||||
name => $validation->param('token'),
|
||||
used => 0,
|
||||
})->update({ used => 1 });
|
||||
$c->schema->resultset('User')->create({
|
||||
|
|
|
@ -35,7 +35,7 @@ sub register {
|
|||
$validation->required('email')->email->not_in_resultset('email', $user_rs);
|
||||
|
||||
my $token_rs = $c->schema->resultset('AccountToken')->search_rs({used => 0});
|
||||
$validation->required('token')->in_resultset('accounttokenname', $token_rs);
|
||||
$validation->required('token')->in_resultset('name', $token_rs);
|
||||
|
||||
my $age_rs = $c->schema->resultset('AgeRange');
|
||||
$validation->required('agerange')->in_resultset('id', $age_rs);
|
||||
|
|
|
@ -1,98 +1,24 @@
|
|||
use utf8;
|
||||
package Pear::LocalLoop::Schema::Result::AccountToken;
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader
|
||||
# DO NOT MODIFY THE FIRST PART OF THIS FILE
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Pear::LocalLoop::Schema::Result::AccountToken
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
=head1 COMPONENTS LOADED
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L<DBIx::Class::InflateColumn::DateTime>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->load_components("InflateColumn::DateTime");
|
||||
|
||||
=head1 TABLE: C<AccountTokens>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->table("AccountTokens");
|
||||
|
||||
=head1 ACCESSORS
|
||||
|
||||
=head2 accounttokenid
|
||||
|
||||
data_type: 'integer'
|
||||
is_auto_increment: 1
|
||||
is_nullable: 0
|
||||
|
||||
=head2 accounttokenname
|
||||
|
||||
data_type: 'text'
|
||||
is_nullable: 0
|
||||
|
||||
=head2 used
|
||||
|
||||
data_type: 'integer'
|
||||
default_value: 0
|
||||
is_nullable: 0
|
||||
|
||||
=cut
|
||||
__PACKAGE__->table("account_tokens");
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"accounttokenid",
|
||||
"id",
|
||||
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
|
||||
"accounttokenname",
|
||||
"name",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
"used",
|
||||
{ data_type => "integer", default_value => 0, is_nullable => 0 },
|
||||
);
|
||||
|
||||
=head1 PRIMARY KEY
|
||||
__PACKAGE__->set_primary_key("id");
|
||||
|
||||
=over 4
|
||||
__PACKAGE__->add_unique_constraint(["name"]);
|
||||
|
||||
=item * L</accounttokenid>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->set_primary_key("accounttokenid");
|
||||
|
||||
=head1 UNIQUE CONSTRAINTS
|
||||
|
||||
=head2 C<accounttokenname_unique>
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L</accounttokenname>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->add_unique_constraint("accounttokenname_unique", ["accounttokenname"]);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-02-24 17:32:21
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:MeN6dMZY0drrWk+En7E5Ag
|
||||
|
||||
|
||||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
1;
|
||||
|
|
|
@ -5,7 +5,7 @@ use warnings;
|
|||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table("Administrators");
|
||||
__PACKAGE__->table("administrators");
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"user_id",
|
||||
|
|
|
@ -12,7 +12,7 @@ my $dump_error = sub { diag $t->tx->res->dom->at('pre[id="error"]')->text };
|
|||
my @account_tokens = ('a', 'b', 'c');
|
||||
|
||||
$schema->resultset('AccountToken')->populate([
|
||||
[ 'accounttokenname' ],
|
||||
[ 'name' ],
|
||||
map { [ $_ ] } @account_tokens,
|
||||
]);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ my $dump_error = sub { diag $t->tx->res->dom->at('pre[id="error"]')->text };
|
|||
my @account_tokens = ('a', 'b', 'c');
|
||||
|
||||
$schema->resultset('AccountToken')->populate([
|
||||
[ 'accounttokenname' ],
|
||||
[ 'name' ],
|
||||
map { [ $_ ] } @account_tokens,
|
||||
]);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ my $email = 'rufus@shinra.energy';
|
|||
my $password = 'MakoGold';
|
||||
|
||||
$schema->resultset('AccountToken')->create({
|
||||
accounttokenname => $account_token
|
||||
name => $account_token
|
||||
});
|
||||
|
||||
my $test_json = {
|
||||
|
|
|
@ -14,7 +14,7 @@ my @emails = ('a@a.com', 'b@a.com', 'c@a.com', 'd@a.com', 'e@a.com', 'f@a.com',
|
|||
my @tokens = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
|
||||
|
||||
$schema->resultset('AccountToken')->populate([
|
||||
[ qw/ accounttokenname / ],
|
||||
[ qw/ name / ],
|
||||
map { [ $_ ] } @tokens,
|
||||
]);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ my $schema = $t->app->schema;
|
|||
|
||||
my @account_tokens = ('a', 'b');
|
||||
$schema->resultset('AccountToken')->populate([
|
||||
[ qw/ accounttokenname / ],
|
||||
[ qw/ name / ],
|
||||
map { [ $_ ] } @account_tokens,
|
||||
]);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ my $dump_error = sub { diag $t->tx->res->dom->at('pre[id="error"]')->text };
|
|||
my @account_tokens = ('a', 'b', 'c');
|
||||
|
||||
$schema->resultset('AccountToken')->populate([
|
||||
[ 'accounttokenname' ],
|
||||
[ 'name' ],
|
||||
map { [ $_ ] } @account_tokens,
|
||||
]);
|
||||
|
||||
|
|
Reference in a new issue