mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 08:27:32 +00:00
fix: proper error message when user (and other objects) not found (#337)
* fix: proper error message when user not found by loginname * add more not found and fix some typos
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
usr_model "github.com/caos/zitadel/internal/user/model"
|
||||
"github.com/caos/zitadel/internal/user/repository/view/model"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
@@ -11,6 +12,9 @@ func NotifyUserByID(db *gorm.DB, table, userID string) (*model.NotifyUser, error
|
||||
user := new(model.NotifyUser)
|
||||
query := repository.PrepareGetByKey(table, model.UserSearchKey(usr_model.NotifyUserSearchKeyUserID), userID)
|
||||
err := query(db, user)
|
||||
if caos_errs.IsNotFound(err) {
|
||||
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Gad31", "Errors.User.NotFound")
|
||||
}
|
||||
return user, err
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
"github.com/jinzhu/gorm"
|
||||
|
||||
@@ -23,6 +24,9 @@ func UserSessionByIDs(db *gorm.DB, table, agentID, userID string) (*model.UserSe
|
||||
}
|
||||
query := repository.PrepareGetByQuery(table, userAgentQuery, userQuery)
|
||||
err := query(db, userSession)
|
||||
if caos_errs.IsNotFound(err) {
|
||||
return nil, caos_errs.ThrowNotFound(nil, "VIEW-NGBs1", "Errors.UserSession.NotFound")
|
||||
}
|
||||
return userSession, err
|
||||
}
|
||||
|
||||
|
@@ -39,6 +39,9 @@ func UserByLoginName(db *gorm.DB, table, loginName string) (*model.UserView, err
|
||||
}
|
||||
query := repository.PrepareGetByQuery(table, loginNameQuery)
|
||||
err := query(db, user)
|
||||
if caos_errs.IsNotFound(err) {
|
||||
return nil, caos_errs.ThrowNotFound(nil, "VIEW-AD4qs", "Errors.User.NotFound")
|
||||
}
|
||||
return user, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user