1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-05 05:25:27 +02:00

Get firstname and lastname from CAS attributes

This commit is contained in:
Derek Chen 2019-08-17 22:13:37 +08:00
parent 15e687841f
commit fbb73560c0
2 changed files with 30 additions and 1 deletions

View file

@ -112,7 +112,15 @@ func (h *Handler) Authenticate(w http.ResponseWriter, r *http.Request) {
u.Admin = false
u.GlobalAdmin = false
u.Email = userInfo.User
u.Initials = stringutil.MakeInitials(userInfo.User, "")
firstName := userInfo.Attributes.Get("first_name")
lastName := userInfo.Attributes.Get("last_name")
if firstName != "" || lastName != "" {
u.Initials = stringutil.MakeInitials(firstName, lastName)
}else {
u.Initials = stringutil.MakeInitials(userInfo.User, "")
}
u.Salt = secrets.GenerateSalt()
u.Password = secrets.GeneratePassword(secrets.GenerateRandomPassword(), u.Salt)