Document make_context_closure().
[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
81393881 7use namespace::clean -except => [ qw(meta) ];
8extends Action;
9
10
11
12has 'username' => (isa => SimpleStr, is => 'rw', lazy_fail => 1);
13has 'password' => (isa => Password, is => 'rw', lazy_fail => 1);
14
15around error_for_attribute => sub {
16 my $super = shift;
17 my ($self, $attr) = @_;
18 my $result = $super->(@_);
19 my $predicate = $attr->get_predicate_method;
20 if (defined $result && $self->$predicate) {
21 return 'Invalid username or password';
22 }
23 return;
24};
25sub do_apply {
26 my $self = shift;
27 my $target = $self->target_model;
28 return $target->login($self->username, $self->password);
7adfd53f 29};
81393881 30__PACKAGE__->meta->make_immutable;
31
7adfd53f 32
331;
34
35=head1 NAME
36
37Reaction::InterfaceModel::Action::User::Login
38
39=head1 DESCRIPTION
40
41=head2 username
42
43=head2 password
44
45=head1 AUTHORS
46
47See L<Reaction::Class> for authors.
48
49=head1 LICENSE
50
51See L<Reaction::Class> for the license.
52
53=cut