Esempio n. 1
0
func userFromGitLabUser(glu *GitLabUser) *model.User {
	user := &model.User{}
	username := glu.Username
	if username == "" {
		username = glu.Login
	}
	user.Username = model.CleanUsername(username)
	splitName := strings.Split(glu.Name, " ")
	if len(splitName) == 2 {
		user.FirstName = splitName[0]
		user.LastName = splitName[1]
	} else if len(splitName) >= 2 {
		user.FirstName = splitName[0]
		user.LastName = strings.Join(splitName[1:], " ")
	} else {
		user.FirstName = glu.Name
	}
	strings.TrimSpace(user.Email)
	user.Email = glu.Email
	userId := strconv.FormatInt(glu.Id, 10)
	user.AuthData = &userId
	user.AuthService = model.USER_AUTH_SERVICE_GITLAB

	return user
}
Esempio n. 2
0
func userFromGoogleUser(gou *GoogleUser) *model.User {
	user := &model.User{}
	username := gou.Email

	user.Username = model.CleanUsername(username)
	splitName := strings.Split(gou.Name, " ")
	if len(splitName) == 2 {
		user.FirstName = splitName[0]
		user.LastName = splitName[1]
	} else if len(splitName) >= 2 {
		user.FirstName = splitName[0]
		user.LastName = strings.Join(splitName[1:], " ")
	} else {
		user.FirstName = gou.Name
	}
	user.Email = gou.Email
	user.AuthData = gou.Id
	user.AuthService = USER_AUTH_SERVICE_GOOGLE

	return user
}