func parseLoginSource(ctx *middleware.Context, u *models.User, sourceID int64, loginName string) { if sourceID == 0 { return } source, err := models.GetLoginSourceByID(sourceID) if err != nil { if models.IsErrAuthenticationNotExist(err) { ctx.APIError(422, "", err) } else { ctx.APIError(500, "GetLoginSourceByID", err) } return } u.LoginType = source.Type u.LoginSource = source.ID u.LoginName = loginName }