fix(be): returns correct error object if user not found

This commit is contained in:
Denis Gukov 2021-08-11 19:54:27 +05:00
parent e5bfe764e0
commit a1b2d2dc7f
2 changed files with 6 additions and 1 deletions

View File

@ -128,7 +128,7 @@ func login(w http.ResponseWriter, r *http.Request) {
user, err := helpers.Store(r).GetUserByLoginOrEmail(login.Auth, login.Auth)
if err != nil && err == db.ErrNotFound {
if err == db.ErrNotFound {
if ldapUser != nil {
// create new LDAP user
user = *ldapUser

View File

@ -201,5 +201,10 @@ func (d *SqlDb) GetUsers(params db.RetrieveQueryParams) (users []db.User, err er
func (d *SqlDb) GetUserByLoginOrEmail(login string, email string) (existingUser db.User, err error) {
err = d.sql.SelectOne(&existingUser, "select * from `user` where email=? or username=?", email, login)
if err == sql.ErrNoRows {
err = db.ErrNotFound
}
return
}