Move default email checking logic into the data service.

This commit is contained in:
Paulo Reis 2018-08-20 12:15:15 +01:00
parent 47c51257bb
commit 042c959d3a
2 changed files with 7 additions and 3 deletions

View file

@ -25,9 +25,8 @@ define [
resolve:
userDefaultEmail: () ->
UserAffiliationsDataService
.getUserEmails()
.then (userEmails) ->
defaultEmailDetails = _.find userEmails, (userEmail) -> userEmail.default
.getUserDefaultEmail()
.then (defaultEmailDetails) ->
return defaultEmailDetails?.email or null
.catch () -> null
)

View file

@ -31,6 +31,10 @@ define [
$http.get "/user/emails"
.then (response) -> response.data
getUserDefaultEmail = () ->
getUserEmails().then (userEmails) ->
_.find userEmails, (userEmail) -> userEmail.default
getUniversitiesFromCountry = (country) ->
if universities[country.code]?
universitiesFromCountry = universities[country.code]
@ -118,6 +122,7 @@ define [
getDefaultRoleHints
getDefaultDepartmentHints
getUserEmails
getUserDefaultEmail
getUniversitiesFromCountry
getUniversityDomainFromPartialDomainInput
getUniversityDetails