| 1 | package CatalystX::SimpleLogin::Form::LoginOpenID; | ||
| 2 | use HTML::FormHandler::Moose::Role; | ||
| 3 | |||
| 4 | use MooseX::Types::Common::String qw/ NonEmptySimpleStr /; | ||
| 5 | |||
| 6 | BEGIN { | ||
| 7 | unless ( | ||
| 8 | eval { require Crypt::DH } && | ||
| 9 | eval { require Catalyst::Authentication::Credential::OpenID; } | ||
| 10 | ) { | ||
| 11 | warn("Cannot load " . __PACKAGE__ . " - Catalyst OpenID authentication credential not installed\n"); | ||
| 12 | exit 1; | ||
| 13 | } | ||
| 14 | } | ||
| 15 | |||
| 16 | has_field 'openid_identifier' => ( type => 'Text' ); | ||
| 17 | has_field 'openid-check' => ( widget => 'no_render' ); | ||
| 18 | |||
| 19 | has 'openid_error_message' => ( | ||
| 20 | is => 'ro', | ||
| 21 | isa => NonEmptySimpleStr, | ||
| 22 | required => 1, | ||
| 23 | default => 'Invalid OpenID', | ||
| 24 | ); | ||
| 25 | |||
| 26 | after 'add_auth_errors' => sub { | ||
| 27 | my $self = shift; | ||
| 28 | $self->field( 'openid_identifier' )->add_error( $self->openid_error_message ) | ||
| 29 | if $self->field( 'openid-check' )->value or defined $self->field( 'openid_identifier' )->value; | ||
| 30 | }; | ||
| 31 | |||
| 32 | 1; | ||
| 33 | |||
| 34 | =head1 NAME | ||
| 35 | |||
| 36 | CatalystX::SimpleLogin::Form::LoginOpenID - OpenID validation role for the login form | ||
| 37 | |||
| 38 | =head1 DESCRIPTION | ||
| 39 | |||
| 40 | A L<HTML::FormHandler> role form for the login form. | ||
| 41 | |||
| 42 | =head1 FIELDS | ||
| 43 | |||
| 44 | |||
| 45 | =over | ||
| 46 | |||
| 47 | =item openid_identifier | ||
| 48 | |||
| 49 | =item openid-check | ||
| 50 | |||
| 51 | =item openid_error_message | ||
| 52 | |||
| 53 | =back | ||
| 54 | |||
| 55 | =head1 METHODS | ||
| 56 | |||
| 57 | =over | ||
| 58 | |||
| 59 | =item add_auth_errors | ||
| 60 | |||
| 61 | =back | ||
| 62 | |||
| 63 | =head1 SEE ALSO | ||
| 64 | |||
| 65 | =over | ||
| 66 | |||
| 67 | =item L<CatalystX::SimpleLogin::ControllerRole::Login> | ||
| 68 | |||
| 69 | =back | ||
| 70 | |||
| 71 | =head1 AUTHORS | ||
| 72 | |||
| 73 | See L<CatalystX::SimpleLogin> for authors. | ||
| 74 | |||
| 75 | =head1 LICENSE | ||
| 76 | |||
| 77 | See L<CatalystX::SimpleLogin> for license. | ||
| 78 | |||
| 79 | =cut | ||
| 80 |