11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/devise/strategies/meteor.rb', line 11
def authenticate!
self.password = params_auth_hash[:password]
devise_resource = valid_for_params_auth? && mapping.to.find_for_database_authentication(authentication_hash)
meteor_resource = User.where(:emails.elem_match => {address: params_auth_hash[:email]}).first unless devise_resource
resource = devise_resource || meteor_resource
return fail!(:not_found_in_database) unless resource
if meteor_auth_missing?(resource)
new_hashed_password = User.new(:password => password).encrypted_password
resource.services.set(password: {bcrypt: new_hashed_password})
elsif devise_auth_missing?(resource)
email = params_auth_hash[:email]
crypt = resource.services.password[:bcrypt]
unless resource.update_attributes(encrypted_password: crypt, email: email)
fail(resource.unauthenticated_message)
end
resource.reload
elsif both_auth_present?(resource)
else
return pass
end
encrypted = false
if validate(resource) { encrypted = true; resource.valid_password?(password) }
remember_me(resource)
resource.after_database_authentication
success!(resource)
end
mapping.to.new.password = password if !encrypted && Devise.paranoid
fail(:not_found_in_database) unless resource
end
|