Skip to content
Snippets Groups Projects
Verified Commit f754b8fa authored by Björn Geuken's avatar Björn Geuken Committed by Andrej Shadura
Browse files

[api] Move shared code to separate method

Moves code that handles marking succeeded logins to a separate method.
This DRYs the code a bit.

Cherry-picked from: c311c8e7
parent 05f406c1
No related branches found
No related tags found
1 merge request!21OBS SSO implementation
...@@ -238,10 +238,7 @@ class User < ActiveRecord::Base ...@@ -238,10 +238,7 @@ class User < ActiveRecord::Base
if ldap_info if ldap_info
# We've found an ldap authenticated user - find or create an OBS userDB entry. # We've found an ldap authenticated user - find or create an OBS userDB entry.
if user if user
# stuff without affect to update_at user.mark_login!
user.last_logged_in_at = Time.now
user.login_failure_count = 0
self.execute_without_timestamps { user.save! }
# Check for ldap updates # Check for ldap updates
if user.email != ldap_info[0] || user.realname != ldap_info[1] if user.email != ldap_info[0] || user.realname != ldap_info[1]
...@@ -288,9 +285,7 @@ class User < ActiveRecord::Base ...@@ -288,9 +285,7 @@ class User < ActiveRecord::Base
# If the user could be found and the passwords equal then return the user # If the user could be found and the passwords equal then return the user
if user && user.password_equals?(password) if user && user.password_equals?(password)
user.last_logged_in_at = Time.now user.mark_login!
user.login_failure_count = 0
self.execute_without_timestamps { user.save! }
return user return user
end end
...@@ -1042,6 +1037,12 @@ class User < ActiveRecord::Base ...@@ -1042,6 +1037,12 @@ class User < ActiveRecord::Base
User.update_notifications(params, self) User.update_notifications(params, self)
end end
def mark_login!
user.last_logged_in_at = Time.now
user.login_failure_count = 0
User.execute_without_timestamps { user.save! }
end
private private
def can_modify_project_internal(project, ignoreLock) def can_modify_project_internal(project, ignoreLock)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment