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
@@ -6,6 +6,7 @@ package app
|
||||
import (
|
||||
"bytes"
|
||||
b64 "encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -596,7 +597,13 @@ func (a *App) CreateOAuthStateToken(extra string) (*model.Token, *model.AppError
|
||||
token := model.NewToken(model.TOKEN_TYPE_OAUTH, extra)
|
||||
|
||||
if err := a.Srv().Store.Token().Save(token); err != nil {
|
||||
return nil, err
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
return nil, appErr
|
||||
default:
|
||||
return nil, model.NewAppError("CreateOAuthStateToken", "app.recover.save.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
return token, nil
|
||||
|
||||
Ссылка в новой задаче
Block a user