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