TokenStore migration to return plain errors (#14875)
* TokenStore migration to return plain errors * Fix translations * Fix: returned error is ignored and http.StatusBadRequest is always returned * Fix * Fix translations * Suggestions * Changed from BadRequest to NotFound * Setting the correct http status * Changed test to expect 404 status * Fix error
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4df6019f61
Коммит
8b6a5fc5d7
10
app/email.go
10
app/email.go
@@ -571,8 +571,14 @@ func (es *EmailService) CreateVerifyEmailToken(userId string, newEmail string) (
|
||||
|
||||
token := model.NewToken(TOKEN_TYPE_VERIFY_EMAIL, string(jsonData))
|
||||
|
||||
if err := es.srv.Store.Token().Save(token); err != nil {
|
||||
return nil, err
|
||||
if err = es.srv.Store.Token().Save(token); err != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
return nil, appErr
|
||||
default:
|
||||
return nil, model.NewAppError("CreateVerifyEmailToken", "app.recover.save.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return token, nil
|
||||
|
||||
Ссылка в новой задаче
Block a user