1 package Reaction::InterfaceModel::Action::User::Login;
4 use aliased 'Reaction::InterfaceModel::Action';
5 use Reaction::Types::Core qw(SimpleStr Password);
7 use namespace::clean -except => [ qw(meta) ];
10 # Avoid circular ref with target_model for Auth controller login actions.
11 sub BUILD { Scalar::Util::weaken($_[0]->{target_model}) }
13 has 'username' => (isa => SimpleStr, is => 'rw', lazy_fail => 1);
14 has 'password' => (isa => Password, is => 'rw', lazy_fail => 1);
16 around error_for_attribute => sub {
18 my ($self, $attr) = @_;
19 my $result = $super->(@_);
20 my $predicate = $attr->get_predicate_method;
21 if (defined $result && $self->$predicate) {
22 return 'Invalid username or password';
28 my $target = $self->target_model;
29 return $target->login($self->username, $self->password);
31 __PACKAGE__->meta->make_immutable;
38 Reaction::InterfaceModel::Action::User::Login
48 See L<Reaction::Class> for authors.
52 See L<Reaction::Class> for the license.