|
1 |
| -package Catalyst::Authentication::Credential::MediaWords; |
| 1 | +package Catalyst::Authentication::Credential::MediaWords::UsernamePassword; |
2 | 2 |
|
3 | 3 | #
|
4 |
| -# Media Cloud Catalyst credentials package, uses ::DBI::Auth to do the authentication. |
5 |
| -# |
6 |
| -# Adapted from Catalyst::Authentication::Credential::Password. |
| 4 | +# Authenticate users with username and password. |
7 | 5 | #
|
8 | 6 |
|
9 | 7 | use strict;
|
@@ -42,23 +40,20 @@ sub authenticate
|
42 | 40 |
|
43 | 41 | my $db = $c->dbis;
|
44 | 42 |
|
45 |
| - ## because passwords may be in a hashed format, we have to make sure that we remove the |
46 |
| - ## password_field before we pass it to the user routine, as some auth modules use |
47 |
| - ## all data passed to them to find a matching user... |
48 |
| - my $userfindauthinfo = { %{ $authinfo } }; |
49 |
| - delete( $userfindauthinfo->{ $PASSWORD_FIELD } ); |
| 43 | + my $username = $authinfo->{ $USERNAME_FIELD }; |
| 44 | + my $password = $authinfo->{ $PASSWORD_FIELD }; |
50 | 45 |
|
51 |
| - my $user_obj = $realm->find_user( $userfindauthinfo, $c ); |
52 |
| - if ( ref( $user_obj ) ) |
53 |
| - { |
54 |
| - my $username = $authinfo->{ $USERNAME_FIELD }; |
55 |
| - my $password = $authinfo->{ $PASSWORD_FIELD }; |
| 46 | + if ( $username and $password ) { |
56 | 47 |
|
57 | 48 | my $user;
|
58 | 49 | eval { $user = MediaWords::DBI::Auth::Login::login_with_email_password( $c->dbis, $username, $password ); };
|
59 | 50 | unless ( $@ or ( !$user ) )
|
60 | 51 | {
|
61 |
| - return $user_obj; |
| 52 | + my $user_obj = $realm->find_user( { username => $user->email() }, $c ); |
| 53 | + if ( ref( $user_obj ) ) |
| 54 | + { |
| 55 | + return $user_obj; |
| 56 | + } |
62 | 57 | }
|
63 | 58 | }
|
64 | 59 |
|
|
0 commit comments