@@ -156,19 +156,13 class User < Principal | |||||
156 | login = login.to_s |
|
156 | login = login.to_s | |
157 | password = password.to_s |
|
157 | password = password.to_s | |
158 |
|
158 | |||
159 | # Make sure no one can sign in with an empty password |
|
159 | # Make sure no one can sign in with an empty login or password | |
160 | return nil if password.empty? |
|
160 | return nil if login.empty? || password.empty? | |
161 | user = find_by_login(login) |
|
161 | user = find_by_login(login) | |
162 | if user |
|
162 | if user | |
163 | # user is already in local database |
|
163 | # user is already in local database | |
164 |
return nil |
|
164 | return nil unless user.active? | |
165 | if user.auth_source |
|
165 | return nil unless user.check_password?(password) | |
166 | # user has an external authentication method |
|
|||
167 | return nil unless user.auth_source.authenticate(login, password) |
|
|||
168 | else |
|
|||
169 | # authentication with local password |
|
|||
170 | return nil unless user.check_password?(password) |
|
|||
171 | end |
|
|||
172 | else |
|
166 | else | |
173 | # user is not yet registered, try to authenticate with available sources |
|
167 | # user is not yet registered, try to authenticate with available sources | |
174 | attrs = AuthSource.authenticate(login, password) |
|
168 | attrs = AuthSource.authenticate(login, password) |
General Comments 0
You need to be logged in to leave comments.
Login now