// InitializeUser implements Initializer
func (*DefaultUserInitStrategy) InitializeUser(identity *api.Identity, user *api.User) error {
	if identity.Extra != nil {
		if name, ok := identity.Extra["name"]; ok && len(name) > 0 {
			user.FullName = name
		}
	}
	return nil
}
Esempio n. 2
0
// removeIdentityFromUser removes the given identity from the user's list of identities
// returns true if the user's identity list was modified
func removeIdentityFromUser(identity *api.Identity, user *api.User) bool {
	identities := util.NewStringSet(user.Identities...)
	if !identities.Has(identity.Name) {
		return false
	}
	identities.Delete(identity.Name)
	user.Identities = identities.List()
	return true
}
Esempio n. 3
0
// addIdentityToUser adds the given identity to the user's list of identities
// returns true if the user's identity list was modified
func addIdentityToUser(identity *api.Identity, user *api.User) bool {
	identities := util.NewStringSet(user.Identities...)
	if identities.Has(identity.Name) {
		return false
	}
	identities.Insert(identity.Name)
	user.Identities = identities.List()
	return true
}