PLT-2258 Unified login screen and related APIs (#2820)
* Unified login screen and related APIs * Refactored login API call to be less convoluted * Removed LDAP login prompt from invite process * Fixed existing LDAP users being able to log in if LDAP was configured, but disabled * Gofmt * Future proofed login API * Updated login APIs based on feedback * Added additional auditing to login API * Actually removed loginById
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
e76a30bca0
Коммит
87989b8afd
@@ -716,6 +716,47 @@ func (us SqlUserStore) GetByUsername(username string) StoreChannel {
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (us SqlUserStore) GetForLogin(loginId string, allowSignInWithUsername, allowSignInWithEmail, ldapEnabled bool) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
|
||||
params := map[string]interface{}{
|
||||
"LoginId": loginId,
|
||||
"AllowSignInWithUsername": allowSignInWithUsername,
|
||||
"AllowSignInWithEmail": allowSignInWithEmail,
|
||||
"LdapEnabled": ldapEnabled,
|
||||
}
|
||||
|
||||
users := []*model.User{}
|
||||
if _, err := us.GetReplica().Select(
|
||||
&users,
|
||||
`SELECT
|
||||
*
|
||||
FROM
|
||||
Users
|
||||
WHERE
|
||||
(:AllowSignInWithUsername AND Username = :LoginId)
|
||||
OR (:AllowSignInWithEmail AND Email = :LoginId)
|
||||
OR (:LdapEnabled AND AuthService = '`+model.USER_AUTH_SERVICE_LDAP+`' AND AuthData = :LoginId)`,
|
||||
params); err != nil {
|
||||
result.Err = model.NewLocAppError("SqlUserStore.GetForLogin", "store.sql_user.get_for_login.app_error", nil, err.Error())
|
||||
} else if len(users) == 1 {
|
||||
result.Data = users[0]
|
||||
} else if len(users) > 1 {
|
||||
result.Err = model.NewLocAppError("SqlUserStore.GetForLogin", "store.sql_user.get_for_login.multiple_users", nil, "")
|
||||
} else {
|
||||
result.Err = model.NewLocAppError("SqlUserStore.GetForLogin", "store.sql_user.get_for_login.app_error", nil, "")
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
}()
|
||||
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (us SqlUserStore) VerifyEmail(userId string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user