Commit 66f719564872425b50fefb927210fdd71cff75a8
Committed by
Larissa Reis
1 parent
a3c24add
Exists in
federation-webfinger
Ensure that the federated user has e-mail
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
app/concerns/authenticated_system.rb
| ... | ... | @@ -28,7 +28,13 @@ module AuthenticatedSystem |
| 28 | 28 | user = nil |
| 29 | 29 | if session[:external] |
| 30 | 30 | user = User.new #FIXME: User needs to have at least email |
| 31 | - user.external_person_id = session[:external] | |
| 31 | + external_person = ExternalPerson.where(id: session[:external]).last | |
| 32 | + if external_person | |
| 33 | + user.external_person_id = external_person.id | |
| 34 | + user.email = external_person.email | |
| 35 | + else | |
| 36 | + session[:external] = nil | |
| 37 | + end | |
| 32 | 38 | else |
| 33 | 39 | id = session[:user] |
| 34 | 40 | user = User.where(id: id).first if id | ... | ... |
app/models/concerns/external_user.rb
| ... | ... | @@ -44,6 +44,7 @@ module ExternalUser |
| 44 | 44 | user = User.external_login(login, password, domain) |
| 45 | 45 | if user |
| 46 | 46 | u = User.new |
| 47 | + u.email = user['user']['email'] | |
| 47 | 48 | u.login = login |
| 48 | 49 | # FIXME: Instead of the struct below, we should use the "webfinger" object returned by the webfinger_lookup method |
| 49 | 50 | webfinger = OpenStruct.new( | ... | ... |