complete MooseX::Types port
[catagits/Reaction.git] / lib / Reaction / InterfaceModel / Action / User / Login.pm
CommitLineData
7adfd53f 1package Reaction::InterfaceModel::Action::User::Login;
2
3use Reaction::Class;
4use aliased 'Reaction::InterfaceModel::Action';
d9a3266f 5use Reaction::Types::Core qw(SimpleStr Password);
7adfd53f 6
7class Login, is Action, which {
8
d9a3266f 9 has 'username' => (isa => SimpleStr, is => 'rw', lazy_fail => 1);
10 has 'password' => (isa => Password, is => 'rw', lazy_fail => 1);
7adfd53f 11
12 around error_for_attribute => sub {
13 my $super = shift;
14 my ($self, $attr) = @_;
15 my $result = $super->(@_);
16 my $predicate = $attr->predicate;
17 if (defined $result && $self->$predicate) {
18 return 'Invalid username or password';
19 }
20 return;
21 };
22
23 implements do_apply => as {
24 my $self = shift;
25 my $target = $self->target_model;
26 return $target->login($self->username, $self->password);
27 };
28};
29
301;
31
32=head1 NAME
33
34Reaction::InterfaceModel::Action::User::Login
35
36=head1 DESCRIPTION
37
38=head2 username
39
40=head2 password
41
42=head1 AUTHORS
43
44See L<Reaction::Class> for authors.
45
46=head1 LICENSE
47
48See L<Reaction::Class> for the license.
49
50=cut