CatalystX-Eta
view release on metacpan or search on metacpan
t/lib/MyApp/Schema/Result/User.pm view on Meta::CPAN
},
"name",
{ data_type => "text", is_nullable => 0 },
"email",
{ data_type => "text", is_nullable => 0 },
"active",
{ data_type => "int", default_value => "1", is_nullable => 0 },
"created_at",
{
data_type => "timestamp",
default_value => \"current_timestamp",
is_nullable => 0,
original => { default_value => \"current_timestamp" },
},
"password",
{ data_type => "text", is_nullable => 0 },
"type",
{ data_type => "varchar", is_nullable => 1, size => 12 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<user_email_key>
=over 4
=item * L</email>
=back
=cut
__PACKAGE__->add_unique_constraint("user_email_key", ["email"]);
=head1 RELATIONS
=head2 user_roles
Type: has_many
Related object: L<MyApp::Schema::Result::UserRole>
=cut
__PACKAGE__->has_many(
"user_roles",
"MyApp::Schema::Result::UserRole",
{ "foreign.user_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 user_sessions
Type: has_many
Related object: L<MyApp::Schema::Result::UserSession>
=cut
__PACKAGE__->has_many(
"user_sessions",
"MyApp::Schema::Result::UserSession",
{ "foreign.user_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
# Created by DBIx::Class::Schema::Loader v0.07036 @ 2013-10-28 10:35:58
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hQwJLiWhFKujOi7tLqDAlQ
__PACKAGE__->many_to_many( roles => user_roles => 'role' );
__PACKAGE__->remove_column('password');
__PACKAGE__->add_column(
password => {
data_type => "text",
passphrase => 'crypt',
passphrase_class => 'BlowfishCrypt',
passphrase_args => {
cost => 8,
salt_random => 1,
},
passphrase_check_method => 'check_password',
is_nullable => 0
},
);
__PACKAGE__->has_many(
"sessions",
"MyApp::Schema::Result::UserSession",
{ "foreign.user_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
with 'MyApp::Role::Verification';
with 'MyApp::Role::Verification::TransactionalActions::DBIC';
with 'MyApp::Schema::Role::ResultsetFind';
use Data::Verifier;
use MooseX::Types::Email qw/EmailAddress/;
sub verifiers_specs {
my $self = shift;
return {
update => Data::Verifier->new(
filters => [qw(trim)],
profile => {
name => {
required => 0,
type => 'Str',
},
role => {
required => 0,
type => 'Str',
},
email => {
required => 0,
type => EmailAddress,
post_check => sub {
my $r = shift;
return 1 if $self->email eq $r->get_value('email');
return 0 if $self->resultset_find( { email => $r->get_value('email') } );
return 1;
}
},
password => {
required => 0,
type => 'Str',
},
},
),
};
}
sub action_specs {
my $self = shift;
return {
update => sub {
my %values = shift->valid_values;
not defined $values{$_} and delete $values{$_} for keys %values;
( run in 0.827 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )