Automatically confirm existing LDAP users
Users from before the akkounts app existed can log in without an extra email confirmation.
This commit is contained in:
parent
e45d0a4a4f
commit
92d959ffbb
@ -8,8 +8,14 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
def ldap_before_save
|
def ldap_before_save
|
||||||
self.email = Devise::LDAP::Adapter.get_ldap_param(self.cn, "mail").first
|
self.email = Devise::LDAP::Adapter.get_ldap_param(self.cn, "mail").first
|
||||||
|
|
||||||
dn = Devise::LDAP::Adapter.get_ldap_param(self.cn, "dn")
|
dn = Devise::LDAP::Adapter.get_ldap_param(self.cn, "dn")
|
||||||
self.ou = dn.split(',').select{|e| e[0..1] == "ou"}.first.delete_prefix("ou=")
|
self.ou = dn.split(',').select{|e| e[0..1] == "ou"}.first.delete_prefix("ou=")
|
||||||
|
|
||||||
|
if self.confirmed_at.blank? && self.confirmation_token.blank?
|
||||||
|
# User had an account with a trusted email address before akkounts was a thing
|
||||||
|
self.confirmed_at = DateTime.now
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_password(new_password, new_password_confirmation)
|
def reset_password(new_password, new_password_confirmation)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user