Automatic Merge
Этот коммит содержится в:
Rodrigo Villablanca
2020-07-17 06:56:08 -04:00
коммит произвёл GitHub
родитель f596064dff
Коммит 93a537a636
12 изменённых файлов: 348 добавлений и 363 удалений

Просмотреть файл

@@ -35,14 +35,40 @@ func (a *App) CreateOAuthApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppEr
app.ClientSecret = model.NewId() app.ClientSecret = model.NewId()
return a.Srv().Store.OAuth().SaveApp(app) oauthApp, err := a.Srv().Store.OAuth().SaveApp(app)
if err != nil {
var appErr *model.AppError
var invErr *store.ErrInvalidInput
switch {
case errors.As(err, &appErr):
return nil, appErr
case errors.As(err, &invErr):
return nil, model.NewAppError("CreateOAuthApp", "app.oauth.save_app.existing.app_error", nil, invErr.Error(), http.StatusBadRequest)
default:
return nil, model.NewAppError("CreateOAuthApp", "app.oauth.save_app.save.app_error", nil, err.Error(), http.StatusInternalServerError)
}
}
return oauthApp, nil
} }
func (a *App) GetOAuthApp(appId string) (*model.OAuthApp, *model.AppError) { func (a *App) GetOAuthApp(appId string) (*model.OAuthApp, *model.AppError) {
if !*a.Config().ServiceSettings.EnableOAuthServiceProvider { if !*a.Config().ServiceSettings.EnableOAuthServiceProvider {
return nil, model.NewAppError("GetOAuthApp", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented) return nil, model.NewAppError("GetOAuthApp", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
} }
return a.Srv().Store.OAuth().GetApp(appId)
oauthApp, err := a.Srv().Store.OAuth().GetApp(appId)
if err != nil {
var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("GetOAuthApp", "app.oauth.get_app.find.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return nil, model.NewAppError("GetOAuthApp", "app.oauth.get_app.finding.app_error", nil, err.Error(), http.StatusInternalServerError)
}
}
return oauthApp, nil
} }
func (a *App) UpdateOauthApp(oldApp, updatedApp *model.OAuthApp) (*model.OAuthApp, *model.AppError) { func (a *App) UpdateOauthApp(oldApp, updatedApp *model.OAuthApp) (*model.OAuthApp, *model.AppError) {
@@ -55,7 +81,21 @@ func (a *App) UpdateOauthApp(oldApp, updatedApp *model.OAuthApp) (*model.OAuthAp
updatedApp.CreateAt = oldApp.CreateAt updatedApp.CreateAt = oldApp.CreateAt
updatedApp.ClientSecret = oldApp.ClientSecret updatedApp.ClientSecret = oldApp.ClientSecret
return a.Srv().Store.OAuth().UpdateApp(updatedApp) oauthApp, err := a.Srv().Store.OAuth().UpdateApp(updatedApp)
if err != nil {
var appErr *model.AppError
var invErr *store.ErrInvalidInput
switch {
case errors.As(err, &appErr):
return nil, appErr
case errors.As(err, &invErr):
return nil, model.NewAppError("UpdateOauthApp", "app.oauth.update_app.find.app_error", nil, invErr.Error(), http.StatusBadRequest)
default:
return nil, model.NewAppError("UpdateOauthApp", "app.oauth.update_app.updating.app_error", nil, err.Error(), http.StatusInternalServerError)
}
}
return oauthApp, nil
} }
func (a *App) DeleteOAuthApp(appId string) *model.AppError { func (a *App) DeleteOAuthApp(appId string) *model.AppError {
@@ -64,7 +104,7 @@ func (a *App) DeleteOAuthApp(appId string) *model.AppError {
} }
if err := a.Srv().Store.OAuth().DeleteApp(appId); err != nil { if err := a.Srv().Store.OAuth().DeleteApp(appId); err != nil {
return err return model.NewAppError("DeleteOAuthApp", "app.oauth.delete_app.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
if err := a.Srv().InvalidateAllCaches(); err != nil { if err := a.Srv().InvalidateAllCaches(); err != nil {
@@ -79,7 +119,12 @@ func (a *App) GetOAuthApps(page, perPage int) ([]*model.OAuthApp, *model.AppErro
return nil, model.NewAppError("GetOAuthApps", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented) return nil, model.NewAppError("GetOAuthApps", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
} }
return a.Srv().Store.OAuth().GetApps(page*perPage, perPage) oauthApps, err := a.Srv().Store.OAuth().GetApps(page*perPage, perPage)
if err != nil {
return nil, model.NewAppError("GetOAuthApps", "app.oauth.get_apps.find.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return oauthApps, nil
} }
func (a *App) GetOAuthAppsByCreator(userId string, page, perPage int) ([]*model.OAuthApp, *model.AppError) { func (a *App) GetOAuthAppsByCreator(userId string, page, perPage int) ([]*model.OAuthApp, *model.AppError) {
@@ -87,7 +132,12 @@ func (a *App) GetOAuthAppsByCreator(userId string, page, perPage int) ([]*model.
return nil, model.NewAppError("GetOAuthAppsByUser", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented) return nil, model.NewAppError("GetOAuthAppsByUser", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
} }
return a.Srv().Store.OAuth().GetAppByUser(userId, page*perPage, perPage) oauthApps, err := a.Srv().Store.OAuth().GetAppByUser(userId, page*perPage, perPage)
if err != nil {
return nil, model.NewAppError("GetOAuthAppsByCreator", "app.oauth.get_app_by_user.find.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return oauthApps, nil
} }
func (a *App) GetOAuthImplicitRedirect(userId string, authRequest *model.AuthorizeRequest) (string, *model.AppError) { func (a *App) GetOAuthImplicitRedirect(userId string, authRequest *model.AuthorizeRequest) (string, *model.AppError) {
@@ -126,9 +176,15 @@ func (a *App) AllowOAuthAppAccessToUser(userId string, authRequest *model.Author
authRequest.Scope = model.DEFAULT_SCOPE authRequest.Scope = model.DEFAULT_SCOPE
} }
oauthApp, err := a.Srv().Store.OAuth().GetApp(authRequest.ClientId) oauthApp, nErr := a.Srv().Store.OAuth().GetApp(authRequest.ClientId)
if err != nil { if nErr != nil {
return "", err var nfErr *store.ErrNotFound
switch {
case errors.As(nErr, &nfErr):
return "", model.NewAppError("AllowOAuthAppAccessToUser", "app.oauth.get_app.find.app_error", nil, nfErr.Error(), http.StatusNotFound)
default:
return "", model.NewAppError("AllowOAuthAppAccessToUser", "app.oauth.get_app.finding.app_error", nil, nErr.Error(), http.StatusInternalServerError)
}
} }
if !oauthApp.IsValidRedirectURL(authRequest.RedirectUri) { if !oauthApp.IsValidRedirectURL(authRequest.RedirectUri) {
@@ -136,7 +192,7 @@ func (a *App) AllowOAuthAppAccessToUser(userId string, authRequest *model.Author
} }
var redirectURI string var redirectURI string
var err *model.AppError
switch authRequest.ResponseType { switch authRequest.ResponseType {
case model.AUTHCODE_RESPONSE_TYPE: case model.AUTHCODE_RESPONSE_TYPE:
redirectURI, err = a.GetOAuthCodeRedirect(userId, authRequest) redirectURI, err = a.GetOAuthCodeRedirect(userId, authRequest)
@@ -202,8 +258,8 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.disabled.app_error", nil, "", http.StatusNotImplemented) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.disabled.app_error", nil, "", http.StatusNotImplemented)
} }
oauthApp, err := a.Srv().Store.OAuth().GetApp(clientId) oauthApp, nErr := a.Srv().Store.OAuth().GetApp(clientId)
if err != nil { if nErr != nil {
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.credentials.app_error", nil, "", http.StatusNotFound) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.credentials.app_error", nil, "", http.StatusNotFound)
} }
@@ -211,18 +267,19 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.credentials.app_error", nil, "", http.StatusForbidden) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.credentials.app_error", nil, "", http.StatusForbidden)
} }
var user *model.User
var accessData *model.AccessData var accessData *model.AccessData
var accessRsp *model.AccessResponse var accessRsp *model.AccessResponse
if grantType == model.ACCESS_TOKEN_GRANT_TYPE { if grantType == model.ACCESS_TOKEN_GRANT_TYPE {
var authData *model.AuthData var authData *model.AuthData
authData, err = a.Srv().Store.OAuth().GetAuthData(code) authData, nErr = a.Srv().Store.OAuth().GetAuthData(code)
if err != nil { if nErr != nil {
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.expired_code.app_error", nil, "", http.StatusBadRequest) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.expired_code.app_error", nil, "", http.StatusBadRequest)
} }
if authData.IsExpired() { if authData.IsExpired() {
a.Srv().Store.OAuth().RemoveAuthData(authData.Code) if nErr = a.Srv().Store.OAuth().RemoveAuthData(authData.Code); nErr != nil {
mlog.Warn("unable to remove auth data", mlog.Err(nErr))
}
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.expired_code.app_error", nil, "", http.StatusForbidden) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.expired_code.app_error", nil, "", http.StatusForbidden)
} }
@@ -230,13 +287,13 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.redirect_uri.app_error", nil, "", http.StatusBadRequest) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.redirect_uri.app_error", nil, "", http.StatusBadRequest)
} }
user, err = a.Srv().Store.User().Get(authData.UserId) user, err := a.Srv().Store.User().Get(authData.UserId)
if err != nil { if err != nil {
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_user.app_error", nil, "", http.StatusNotFound) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_user.app_error", nil, "", http.StatusNotFound)
} }
accessData, err = a.Srv().Store.OAuth().GetPreviousAccessData(user.Id, clientId) accessData, nErr = a.Srv().Store.OAuth().GetPreviousAccessData(user.Id, clientId)
if err != nil { if nErr != nil {
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal.app_error", nil, "", http.StatusBadRequest) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal.app_error", nil, "", http.StatusBadRequest)
} }
@@ -267,8 +324,8 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
accessData = &model.AccessData{ClientId: clientId, UserId: user.Id, Token: session.Token, RefreshToken: model.NewId(), RedirectUri: redirectUri, ExpiresAt: session.ExpiresAt, Scope: authData.Scope} accessData = &model.AccessData{ClientId: clientId, UserId: user.Id, Token: session.Token, RefreshToken: model.NewId(), RedirectUri: redirectUri, ExpiresAt: session.ExpiresAt, Scope: authData.Scope}
if _, err = a.Srv().Store.OAuth().SaveAccessData(accessData); err != nil { if _, nErr = a.Srv().Store.OAuth().SaveAccessData(accessData); nErr != nil {
mlog.Error("error saving oauth access data in token for code flow", mlog.Err(err)) mlog.Error("error saving oauth access data in token for code flow", mlog.Err(nErr))
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.internal_saving.app_error", nil, "", http.StatusInternalServerError)
} }
@@ -280,11 +337,13 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, c
} }
} }
a.Srv().Store.OAuth().RemoveAuthData(authData.Code) if nErr = a.Srv().Store.OAuth().RemoveAuthData(authData.Code); nErr != nil {
mlog.Warn("unable to remove auth data", mlog.Err(nErr))
}
} else { } else {
// When grantType is refresh_token // When grantType is refresh_token
accessData, err = a.Srv().Store.OAuth().GetAccessDataByRefreshToken(refreshToken) accessData, nErr = a.Srv().Store.OAuth().GetAccessDataByRefreshToken(refreshToken)
if err != nil { if nErr != nil {
return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.refresh_token.app_error", nil, "", http.StatusNotFound) return nil, model.NewAppError("GetOAuthAccessToken", "api.oauth.get_access_token.refresh_token.app_error", nil, "", http.StatusNotFound)
} }
@@ -394,7 +453,7 @@ func (a *App) GetAuthorizedAppsForUser(userId string, page, perPage int) ([]*mod
apps, err := a.Srv().Store.OAuth().GetAuthorizedApps(userId, page*perPage, perPage) apps, err := a.Srv().Store.OAuth().GetAuthorizedApps(userId, page*perPage, perPage)
if err != nil { if err != nil {
return nil, err return nil, model.NewAppError("GetAuthorizedAppsForUser", "app.oauth.get_apps.find.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
for k, a := range apps { for k, a := range apps {
@@ -413,7 +472,7 @@ func (a *App) DeauthorizeOAuthAppForUser(userId, appId string) *model.AppError {
// Revoke app sessions // Revoke app sessions
accessData, err := a.Srv().Store.OAuth().GetAccessDataByUserForApp(userId, appId) accessData, err := a.Srv().Store.OAuth().GetAccessDataByUserForApp(userId, appId)
if err != nil { if err != nil {
return err return model.NewAppError("DeauthorizeOAuthAppForUser", "app.oauth.get_access_data_by_user_for_app.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
for _, ad := range accessData { for _, ad := range accessData {
@@ -422,7 +481,7 @@ func (a *App) DeauthorizeOAuthAppForUser(userId, appId string) *model.AppError {
} }
if err := a.Srv().Store.OAuth().RemoveAccessData(ad.Token); err != nil { if err := a.Srv().Store.OAuth().RemoveAccessData(ad.Token); err != nil {
return err return model.NewAppError("DeauthorizeOAuthAppForUser", "app.oauth.remove_access_data.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
} }
@@ -441,7 +500,16 @@ func (a *App) RegenerateOAuthAppSecret(app *model.OAuthApp) (*model.OAuthApp, *m
app.ClientSecret = model.NewId() app.ClientSecret = model.NewId()
if _, err := a.Srv().Store.OAuth().UpdateApp(app); err != nil { if _, err := a.Srv().Store.OAuth().UpdateApp(app); err != nil {
return nil, err var appErr *model.AppError
var invErr *store.ErrInvalidInput
switch {
case errors.As(err, &appErr):
return nil, appErr
case errors.As(err, &invErr):
return nil, model.NewAppError("RegenerateOAuthAppSecret", "app.oauth.update_app.find.app_error", nil, invErr.Error(), http.StatusBadRequest)
default:
return nil, model.NewAppError("RegenerateOAuthAppSecret", "app.oauth.update_app.updating.app_error", nil, err.Error(), http.StatusInternalServerError)
}
} }
return app, nil return app, nil

Просмотреть файл

@@ -90,8 +90,8 @@ func TestOAuthRevokeAccessToken(t *testing.T) {
accessData.ClientId = model.NewId() accessData.ClientId = model.NewId()
accessData.ExpiresAt = session.ExpiresAt accessData.ExpiresAt = session.ExpiresAt
_, err = th.App.Srv().Store.OAuth().SaveAccessData(accessData) _, nErr := th.App.Srv().Store.OAuth().SaveAccessData(accessData)
require.Nil(t, err) require.Nil(t, nErr)
err = th.App.RevokeAccessToken(accessData.Token) err = th.App.RevokeAccessToken(accessData.Token)
require.Nil(t, err) require.Nil(t, err)
@@ -130,8 +130,8 @@ func TestOAuthDeleteApp(t *testing.T) {
accessData.ClientId = a1.Id accessData.ClientId = a1.Id
accessData.ExpiresAt = session.ExpiresAt accessData.ExpiresAt = session.ExpiresAt
_, err = th.App.Srv().Store.OAuth().SaveAccessData(accessData) _, nErr := th.App.Srv().Store.OAuth().SaveAccessData(accessData)
require.Nil(t, err) require.Nil(t, nErr)
err = th.App.DeleteOAuthApp(a1.Id) err = th.App.DeleteOAuthApp(a1.Id)
require.Nil(t, err) require.Nil(t, err)

Просмотреть файл

@@ -153,9 +153,9 @@ func (a *App) RevokeAllSessions(userId string) *model.AppError {
// in the server and revoke them // in the server and revoke them
func (a *App) RevokeSessionsFromAllUsers() *model.AppError { func (a *App) RevokeSessionsFromAllUsers() *model.AppError {
// revoke tokens before sessions so they can't be used to relogin // revoke tokens before sessions so they can't be used to relogin
tErr := a.Srv().Store.OAuth().RemoveAllAccessData() nErr := a.Srv().Store.OAuth().RemoveAllAccessData()
if tErr != nil { if nErr != nil {
return tErr return model.NewAppError("RevokeSessionsFromAllUsers", "app.oauth.remove_access_data.app_error", nil, nErr.Error(), http.StatusInternalServerError)
} }
err := a.Srv().Store.Session().RemoveAllSessions() err := a.Srv().Store.Session().RemoveAllSessions()
if err != nil { if err != nil {

Просмотреть файл

@@ -1461,7 +1461,7 @@ func (a *App) PermanentDeleteUser(user *model.User) *model.AppError {
} }
if err := a.Srv().Store.OAuth().PermanentDeleteAuthDataByUser(user.Id); err != nil { if err := a.Srv().Store.OAuth().PermanentDeleteAuthDataByUser(user.Id); err != nil {
return err return model.NewAppError("PermanentDeleteUser", "app.oauth.permanent_delete_auth_data_by_user.app_error", nil, err.Error(), http.StatusInternalServerError)
} }
if err := a.Srv().Store.Webhook().PermanentDeleteIncomingByUser(user.Id); err != nil { if err := a.Srv().Store.Webhook().PermanentDeleteIncomingByUser(user.Id); err != nil {

Просмотреть файл

@@ -3850,6 +3850,54 @@
"id": "app.notification.subject.notification.full", "id": "app.notification.subject.notification.full",
"translation": "[{{ .SiteName }}] Notification in {{ .TeamName}} on {{.Month}} {{.Day}}, {{.Year}}" "translation": "[{{ .SiteName }}] Notification in {{ .TeamName}} on {{.Month}} {{.Day}}, {{.Year}}"
}, },
{
"id": "app.oauth.delete_app.app_error",
"translation": "An error occurred while deleting the OAuth2 App."
},
{
"id": "app.oauth.get_access_data_by_user_for_app.app_error",
"translation": "We encountered an error finding all the access tokens."
},
{
"id": "app.oauth.get_app.find.app_error",
"translation": "Unable to find the requested app."
},
{
"id": "app.oauth.get_app.finding.app_error",
"translation": "We encountered an error finding the app."
},
{
"id": "app.oauth.get_app_by_user.find.app_error",
"translation": "Unable to find any existing apps."
},
{
"id": "app.oauth.get_apps.find.app_error",
"translation": "An error occurred while finding the OAuth2 Apps."
},
{
"id": "app.oauth.permanent_delete_auth_data_by_user.app_error",
"translation": "Unable to remove the authorization code."
},
{
"id": "app.oauth.remove_access_data.app_error",
"translation": "Unable to remove the access token."
},
{
"id": "app.oauth.save_app.existing.app_error",
"translation": "Must call update for existing app."
},
{
"id": "app.oauth.save_app.save.app_error",
"translation": "Unable to save the app."
},
{
"id": "app.oauth.update_app.find.app_error",
"translation": "Unable to find the existing app to update."
},
{
"id": "app.oauth.update_app.updating.app_error",
"translation": "We encountered an error updating the app."
},
{ {
"id": "app.plugin.cluster.save_config.app_error", "id": "app.plugin.cluster.save_config.app_error",
"translation": "The plugin configuration in your config.json file must be updated manually when using ReadOnlyConfig with clustering enabled." "translation": "The plugin configuration in your config.json file must be updated manually when using ReadOnlyConfig with clustering enabled."
@@ -6722,102 +6770,6 @@
"id": "store.sql_job.update.app_error", "id": "store.sql_job.update.app_error",
"translation": "Unable to update the job." "translation": "Unable to update the job."
}, },
{
"id": "store.sql_oauth.delete.commit_transaction.app_error",
"translation": "Unable to commit transaction."
},
{
"id": "store.sql_oauth.delete.open_transaction.app_error",
"translation": "Unable to open transaction to delete the OAuth2 app."
},
{
"id": "store.sql_oauth.delete_app.app_error",
"translation": "An error occurred while deleting the OAuth2 App."
},
{
"id": "store.sql_oauth.get_access_data.app_error",
"translation": "We encountered an error finding the access token."
},
{
"id": "store.sql_oauth.get_access_data_by_user_for_app.app_error",
"translation": "We encountered an error finding all the access tokens."
},
{
"id": "store.sql_oauth.get_app.find.app_error",
"translation": "Unable to find the requested app."
},
{
"id": "store.sql_oauth.get_app.finding.app_error",
"translation": "We encountered an error finding the app."
},
{
"id": "store.sql_oauth.get_app_by_user.find.app_error",
"translation": "Unable to find any existing apps."
},
{
"id": "store.sql_oauth.get_apps.find.app_error",
"translation": "An error occurred while finding the OAuth2 Apps."
},
{
"id": "store.sql_oauth.get_auth_data.find.app_error",
"translation": "Unable to find the existing authorization code."
},
{
"id": "store.sql_oauth.get_auth_data.finding.app_error",
"translation": "We encountered an error finding the authorization code."
},
{
"id": "store.sql_oauth.get_previous_access_data.app_error",
"translation": "We encountered an error finding the access token."
},
{
"id": "store.sql_oauth.permanent_delete_auth_data_by_user.app_error",
"translation": "Unable to remove the authorization code."
},
{
"id": "store.sql_oauth.remove_access_data.app_error",
"translation": "Unable to remove the access token."
},
{
"id": "store.sql_oauth.remove_auth_data.app_error",
"translation": "Unable to remove the authorization code."
},
{
"id": "store.sql_oauth.save_access_data.app_error",
"translation": "Unable to save the access token."
},
{
"id": "store.sql_oauth.save_app.existing.app_error",
"translation": "Must call update for existing app."
},
{
"id": "store.sql_oauth.save_app.save.app_error",
"translation": "Unable to save the app."
},
{
"id": "store.sql_oauth.save_auth_data.app_error",
"translation": "Unable to save the authorization code."
},
{
"id": "store.sql_oauth.update_access_data.app_error",
"translation": "We encountered an error updating the access token."
},
{
"id": "store.sql_oauth.update_app.find.app_error",
"translation": "Unable to find the existing app to update."
},
{
"id": "store.sql_oauth.update_app.finding.app_error",
"translation": "We encountered an error finding the app."
},
{
"id": "store.sql_oauth.update_app.update.app_error",
"translation": "Unable to update the app."
},
{
"id": "store.sql_oauth.update_app.updating.app_error",
"translation": "We encountered an error updating the app."
},
{ {
"id": "store.sql_plugin_store.compare_and_set.mysql_select.app_error", "id": "store.sql_plugin_store.compare_and_set.mysql_select.app_error",
"translation": "Failed to query for existing row on MySQL after KVCompareAndSet with unchanged value." "translation": "Failed to query for existing row on MySQL after KVCompareAndSet with unchanged value."

Просмотреть файл

@@ -4188,7 +4188,7 @@ func (s *OpenTracingLayerLinkMetadataStore) Save(linkMetadata *model.LinkMetadat
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) DeleteApp(id string) *model.AppError { func (s *OpenTracingLayerOAuthStore) DeleteApp(id string) error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.DeleteApp") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.DeleteApp")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4206,7 +4206,7 @@ func (s *OpenTracingLayerOAuthStore) DeleteApp(id string) *model.AppError {
return resultVar0 return resultVar0
} }
func (s *OpenTracingLayerOAuthStore) GetAccessData(token string) (*model.AccessData, *model.AppError) { func (s *OpenTracingLayerOAuthStore) GetAccessData(token string) (*model.AccessData, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAccessData") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAccessData")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4224,7 +4224,7 @@ func (s *OpenTracingLayerOAuthStore) GetAccessData(token string) (*model.AccessD
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, *model.AppError) { func (s *OpenTracingLayerOAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAccessDataByRefreshToken") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAccessDataByRefreshToken")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4242,7 +4242,7 @@ func (s *OpenTracingLayerOAuthStore) GetAccessDataByRefreshToken(token string) (
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) GetAccessDataByUserForApp(userId string, clientId string) ([]*model.AccessData, *model.AppError) { func (s *OpenTracingLayerOAuthStore) GetAccessDataByUserForApp(userId string, clientId string) ([]*model.AccessData, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAccessDataByUserForApp") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAccessDataByUserForApp")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4260,7 +4260,7 @@ func (s *OpenTracingLayerOAuthStore) GetAccessDataByUserForApp(userId string, cl
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) GetApp(id string) (*model.OAuthApp, *model.AppError) { func (s *OpenTracingLayerOAuthStore) GetApp(id string) (*model.OAuthApp, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetApp") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetApp")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4278,7 +4278,7 @@ func (s *OpenTracingLayerOAuthStore) GetApp(id string) (*model.OAuthApp, *model.
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) GetAppByUser(userId string, offset int, limit int) ([]*model.OAuthApp, *model.AppError) { func (s *OpenTracingLayerOAuthStore) GetAppByUser(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAppByUser") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAppByUser")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4296,7 +4296,7 @@ func (s *OpenTracingLayerOAuthStore) GetAppByUser(userId string, offset int, lim
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, *model.AppError) { func (s *OpenTracingLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetApps") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetApps")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4314,7 +4314,7 @@ func (s *OpenTracingLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OA
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) GetAuthData(code string) (*model.AuthData, *model.AppError) { func (s *OpenTracingLayerOAuthStore) GetAuthData(code string) (*model.AuthData, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAuthData") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAuthData")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4332,7 +4332,7 @@ func (s *OpenTracingLayerOAuthStore) GetAuthData(code string) (*model.AuthData,
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) GetAuthorizedApps(userId string, offset int, limit int) ([]*model.OAuthApp, *model.AppError) { func (s *OpenTracingLayerOAuthStore) GetAuthorizedApps(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAuthorizedApps") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetAuthorizedApps")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4350,7 +4350,7 @@ func (s *OpenTracingLayerOAuthStore) GetAuthorizedApps(userId string, offset int
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) GetPreviousAccessData(userId string, clientId string) (*model.AccessData, *model.AppError) { func (s *OpenTracingLayerOAuthStore) GetPreviousAccessData(userId string, clientId string) (*model.AccessData, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetPreviousAccessData") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.GetPreviousAccessData")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4368,7 +4368,7 @@ func (s *OpenTracingLayerOAuthStore) GetPreviousAccessData(userId string, client
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) PermanentDeleteAuthDataByUser(userId string) *model.AppError { func (s *OpenTracingLayerOAuthStore) PermanentDeleteAuthDataByUser(userId string) error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.PermanentDeleteAuthDataByUser") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.PermanentDeleteAuthDataByUser")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4386,7 +4386,7 @@ func (s *OpenTracingLayerOAuthStore) PermanentDeleteAuthDataByUser(userId string
return resultVar0 return resultVar0
} }
func (s *OpenTracingLayerOAuthStore) RemoveAccessData(token string) *model.AppError { func (s *OpenTracingLayerOAuthStore) RemoveAccessData(token string) error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.RemoveAccessData") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.RemoveAccessData")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4404,7 +4404,7 @@ func (s *OpenTracingLayerOAuthStore) RemoveAccessData(token string) *model.AppEr
return resultVar0 return resultVar0
} }
func (s *OpenTracingLayerOAuthStore) RemoveAllAccessData() *model.AppError { func (s *OpenTracingLayerOAuthStore) RemoveAllAccessData() error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.RemoveAllAccessData") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.RemoveAllAccessData")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4422,7 +4422,7 @@ func (s *OpenTracingLayerOAuthStore) RemoveAllAccessData() *model.AppError {
return resultVar0 return resultVar0
} }
func (s *OpenTracingLayerOAuthStore) RemoveAuthData(code string) *model.AppError { func (s *OpenTracingLayerOAuthStore) RemoveAuthData(code string) error {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.RemoveAuthData") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.RemoveAuthData")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4440,7 +4440,7 @@ func (s *OpenTracingLayerOAuthStore) RemoveAuthData(code string) *model.AppError
return resultVar0 return resultVar0
} }
func (s *OpenTracingLayerOAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) { func (s *OpenTracingLayerOAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.SaveAccessData") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.SaveAccessData")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4458,7 +4458,7 @@ func (s *OpenTracingLayerOAuthStore) SaveAccessData(accessData *model.AccessData
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) { func (s *OpenTracingLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.SaveApp") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.SaveApp")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4476,7 +4476,7 @@ func (s *OpenTracingLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthA
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, *model.AppError) { func (s *OpenTracingLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.SaveAuthData") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.SaveAuthData")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4494,7 +4494,7 @@ func (s *OpenTracingLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*mo
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) { func (s *OpenTracingLayerOAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.UpdateAccessData") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.UpdateAccessData")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)
@@ -4512,7 +4512,7 @@ func (s *OpenTracingLayerOAuthStore) UpdateAccessData(accessData *model.AccessDa
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *OpenTracingLayerOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) { func (s *OpenTracingLayerOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, error) {
origCtx := s.Root.Store.Context() origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.UpdateApp") span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "OAuthStore.UpdateApp")
s.Root.Store.SetContext(newCtx) s.Root.Store.SetContext(newCtx)

Просмотреть файл

@@ -4,12 +4,14 @@
package sqlstore package sqlstore
import ( import (
"net/http" "database/sql"
"strings" "fmt"
"github.com/mattermost/gorp" "github.com/mattermost/gorp"
"github.com/mattermost/mattermost-server/v5/model" "github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/store" "github.com/mattermost/mattermost-server/v5/store"
"github.com/pkg/errors"
) )
type SqlOAuthStore struct { type SqlOAuthStore struct {
@@ -59,9 +61,9 @@ func (as SqlOAuthStore) createIndexesIfNotExists() {
as.CreateIndexIfNotExists("idx_oauthauthdata_client_id", "OAuthAuthData", "Code") as.CreateIndexIfNotExists("idx_oauthauthdata_client_id", "OAuthAuthData", "Code")
} }
func (as SqlOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) { func (as SqlOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, error) {
if len(app.Id) > 0 { if len(app.Id) > 0 {
return nil, model.NewAppError("SqlOAuthStore.SaveApp", "store.sql_oauth.save_app.existing.app_error", nil, "app_id="+app.Id, http.StatusBadRequest) return nil, store.NewErrInvalidInput("OAuthApp", "Id", app.Id)
} }
app.PreSave() app.PreSave()
@@ -70,12 +72,12 @@ func (as SqlOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, *model.Ap
} }
if err := as.GetMaster().Insert(app); err != nil { if err := as.GetMaster().Insert(app); err != nil {
return nil, model.NewAppError("SqlOAuthStore.SaveApp", "store.sql_oauth.save_app.save.app_error", nil, "app_id="+app.Id+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to save OAuthApp")
} }
return app, nil return app, nil
} }
func (as SqlOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) { func (as SqlOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, error) {
app.PreUpdate() app.PreUpdate()
if err := app.IsValid(); err != nil { if err := app.IsValid(); err != nil {
@@ -84,10 +86,10 @@ func (as SqlOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, *model.
oldAppResult, err := as.GetMaster().Get(model.OAuthApp{}, app.Id) oldAppResult, err := as.GetMaster().Get(model.OAuthApp{}, app.Id)
if err != nil { if err != nil {
return nil, model.NewAppError("SqlOAuthStore.UpdateApp", "store.sql_oauth.update_app.finding.app_error", nil, "app_id="+app.Id+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to get OAuthApp with id=%s", app.Id)
} }
if oldAppResult == nil { if oldAppResult == nil {
return nil, model.NewAppError("SqlOAuthStore.UpdateApp", "store.sql_oauth.update_app.find.app_error", nil, "app_id="+app.Id, http.StatusBadRequest) return nil, store.NewErrInvalidInput("OAuthApp", "Id", app.Id)
} }
oldApp := oldAppResult.(*model.OAuthApp) oldApp := oldAppResult.(*model.OAuthApp)
@@ -96,62 +98,62 @@ func (as SqlOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, *model.
count, err := as.GetMaster().Update(app) count, err := as.GetMaster().Update(app)
if err != nil { if err != nil {
return nil, model.NewAppError("SqlOAuthStore.UpdateApp", "store.sql_oauth.update_app.updating.app_error", nil, "app_id="+app.Id+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to update OAuthApp with id=%s", app.Id)
} }
if count != 1 { if count != 1 {
return nil, model.NewAppError("SqlOAuthStore.UpdateApp", "store.sql_oauth.update_app.update.app_error", nil, "app_id="+app.Id, http.StatusBadRequest) return nil, store.NewErrInvalidInput("OAuthApp", "Id", app.Id)
} }
return app, nil return app, nil
} }
func (as SqlOAuthStore) GetApp(id string) (*model.OAuthApp, *model.AppError) { func (as SqlOAuthStore) GetApp(id string) (*model.OAuthApp, error) {
obj, err := as.GetReplica().Get(model.OAuthApp{}, id) obj, err := as.GetReplica().Get(model.OAuthApp{}, id)
if err != nil { if err != nil {
return nil, model.NewAppError("SqlOAuthStore.GetApp", "store.sql_oauth.get_app.finding.app_error", nil, "app_id="+id+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to get OAuthApp with id=%s", id)
} }
if obj == nil { if obj == nil {
return nil, model.NewAppError("SqlOAuthStore.GetApp", "store.sql_oauth.get_app.find.app_error", nil, "app_id="+id, http.StatusNotFound) return nil, store.NewErrNotFound("OAuthApp", id)
} }
return obj.(*model.OAuthApp), nil return obj.(*model.OAuthApp), nil
} }
func (as SqlOAuthStore) GetAppByUser(userId string, offset, limit int) ([]*model.OAuthApp, *model.AppError) { func (as SqlOAuthStore) GetAppByUser(userId string, offset, limit int) ([]*model.OAuthApp, error) {
var apps []*model.OAuthApp var apps []*model.OAuthApp
if _, err := as.GetReplica().Select(&apps, "SELECT * FROM OAuthApps WHERE CreatorId = :UserId LIMIT :Limit OFFSET :Offset", map[string]interface{}{"UserId": userId, "Offset": offset, "Limit": limit}); err != nil { if _, err := as.GetReplica().Select(&apps, "SELECT * FROM OAuthApps WHERE CreatorId = :UserId LIMIT :Limit OFFSET :Offset", map[string]interface{}{"UserId": userId, "Offset": offset, "Limit": limit}); err != nil {
return nil, model.NewAppError("SqlOAuthStore.GetAppByUser", "store.sql_oauth.get_app_by_user.find.app_error", nil, "user_id="+userId+", "+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find OAuthApps with userId=%s", userId)
} }
return apps, nil return apps, nil
} }
func (as SqlOAuthStore) GetApps(offset, limit int) ([]*model.OAuthApp, *model.AppError) { func (as SqlOAuthStore) GetApps(offset, limit int) ([]*model.OAuthApp, error) {
var apps []*model.OAuthApp var apps []*model.OAuthApp
if _, err := as.GetReplica().Select(&apps, "SELECT * FROM OAuthApps LIMIT :Limit OFFSET :Offset", map[string]interface{}{"Offset": offset, "Limit": limit}); err != nil { if _, err := as.GetReplica().Select(&apps, "SELECT * FROM OAuthApps LIMIT :Limit OFFSET :Offset", map[string]interface{}{"Offset": offset, "Limit": limit}); err != nil {
return nil, model.NewAppError("SqlOAuthStore.GetAppByUser", "store.sql_oauth.get_apps.find.app_error", nil, "err="+err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to find OAuthApps")
} }
return apps, nil return apps, nil
} }
func (as SqlOAuthStore) GetAuthorizedApps(userId string, offset, limit int) ([]*model.OAuthApp, *model.AppError) { func (as SqlOAuthStore) GetAuthorizedApps(userId string, offset, limit int) ([]*model.OAuthApp, error) {
var apps []*model.OAuthApp var apps []*model.OAuthApp
if _, err := as.GetReplica().Select(&apps, if _, err := as.GetReplica().Select(&apps,
`SELECT o.* FROM OAuthApps AS o INNER JOIN `SELECT o.* FROM OAuthApps AS o INNER JOIN
Preferences AS p ON p.Name=o.Id AND p.UserId=:UserId LIMIT :Limit OFFSET :Offset`, map[string]interface{}{"UserId": userId, "Offset": offset, "Limit": limit}); err != nil { Preferences AS p ON p.Name=o.Id AND p.UserId=:UserId LIMIT :Limit OFFSET :Offset`, map[string]interface{}{"UserId": userId, "Offset": offset, "Limit": limit}); err != nil {
return nil, model.NewAppError("SqlOAuthStore.GetAuthorizedApps", "store.sql_oauth.get_apps.find.app_error", nil, "err="+err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find OAuthApps with userId=%s", userId)
} }
return apps, nil return apps, nil
} }
func (as SqlOAuthStore) DeleteApp(id string) *model.AppError { func (as SqlOAuthStore) DeleteApp(id string) error {
// wrap in a transaction so that if one fails, everything fails // wrap in a transaction so that if one fails, everything fails
transaction, err := as.GetMaster().Begin() transaction, err := as.GetMaster().Begin()
if err != nil { if err != nil {
return model.NewAppError("SqlOAuthStore.DeleteApp", "store.sql_oauth.delete.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "begin_transaction")
} }
defer finalizeTransaction(transaction) defer finalizeTransaction(transaction)
@@ -161,139 +163,139 @@ func (as SqlOAuthStore) DeleteApp(id string) *model.AppError {
if err := transaction.Commit(); err != nil { if err := transaction.Commit(); err != nil {
// don't need to rollback here since the transaction is already closed // don't need to rollback here since the transaction is already closed
return model.NewAppError("SqlOAuthStore.DeleteApp", "store.sql_oauth.delete.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "commit_transaction")
} }
return nil return nil
} }
func (as SqlOAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) { func (as SqlOAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, error) {
if err := accessData.IsValid(); err != nil { if err := accessData.IsValid(); err != nil {
return nil, err return nil, err
} }
if err := as.GetMaster().Insert(accessData); err != nil { if err := as.GetMaster().Insert(accessData); err != nil {
return nil, model.NewAppError("SqlOAuthStore.SaveAccessData", "store.sql_oauth.save_access_data.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to save AccessData")
} }
return accessData, nil return accessData, nil
} }
func (as SqlOAuthStore) GetAccessData(token string) (*model.AccessData, *model.AppError) { func (as SqlOAuthStore) GetAccessData(token string) (*model.AccessData, error) {
accessData := model.AccessData{} accessData := model.AccessData{}
if err := as.GetReplica().SelectOne(&accessData, "SELECT * FROM OAuthAccessData WHERE Token = :Token", map[string]interface{}{"Token": token}); err != nil { if err := as.GetReplica().SelectOne(&accessData, "SELECT * FROM OAuthAccessData WHERE Token = :Token", map[string]interface{}{"Token": token}); err != nil {
return nil, model.NewAppError("SqlOAuthStore.GetAccessData", "store.sql_oauth.get_access_data.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to get OAuthAccessData with token=%s", token)
} }
return &accessData, nil return &accessData, nil
} }
func (as SqlOAuthStore) GetAccessDataByUserForApp(userId, clientId string) ([]*model.AccessData, *model.AppError) { func (as SqlOAuthStore) GetAccessDataByUserForApp(userId, clientId string) ([]*model.AccessData, error) {
var accessData []*model.AccessData var accessData []*model.AccessData
if _, err := as.GetReplica().Select(&accessData, if _, err := as.GetReplica().Select(&accessData,
"SELECT * FROM OAuthAccessData WHERE UserId = :UserId AND ClientId = :ClientId", "SELECT * FROM OAuthAccessData WHERE UserId = :UserId AND ClientId = :ClientId",
map[string]interface{}{"UserId": userId, "ClientId": clientId}); err != nil { map[string]interface{}{"UserId": userId, "ClientId": clientId}); err != nil {
return nil, model.NewAppError("SqlOAuthStore.GetAccessDataByUserForApp", "store.sql_oauth.get_access_data_by_user_for_app.app_error", nil, "user_id="+userId+" client_id="+clientId, http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to delete OAuthAccessData with userId=%s and clientId=%s", userId, clientId)
} }
return accessData, nil return accessData, nil
} }
func (as SqlOAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, *model.AppError) { func (as SqlOAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, error) {
accessData := model.AccessData{} accessData := model.AccessData{}
if err := as.GetReplica().SelectOne(&accessData, "SELECT * FROM OAuthAccessData WHERE RefreshToken = :Token", map[string]interface{}{"Token": token}); err != nil { if err := as.GetReplica().SelectOne(&accessData, "SELECT * FROM OAuthAccessData WHERE RefreshToken = :Token", map[string]interface{}{"Token": token}); err != nil {
return nil, model.NewAppError("SqlOAuthStore.GetAccessData", "store.sql_oauth.get_access_data.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to find OAuthAccessData with refreshToken=%s", token)
} }
return &accessData, nil return &accessData, nil
} }
func (as SqlOAuthStore) GetPreviousAccessData(userId, clientId string) (*model.AccessData, *model.AppError) { func (as SqlOAuthStore) GetPreviousAccessData(userId, clientId string) (*model.AccessData, error) {
accessData := model.AccessData{} accessData := model.AccessData{}
if err := as.GetReplica().SelectOne(&accessData, "SELECT * FROM OAuthAccessData WHERE ClientId = :ClientId AND UserId = :UserId", if err := as.GetReplica().SelectOne(&accessData, "SELECT * FROM OAuthAccessData WHERE ClientId = :ClientId AND UserId = :UserId",
map[string]interface{}{"ClientId": clientId, "UserId": userId}); err != nil { map[string]interface{}{"ClientId": clientId, "UserId": userId}); err != nil {
if strings.Contains(err.Error(), "no rows") { if err == sql.ErrNoRows {
return nil, nil return nil, nil
} }
return nil, model.NewAppError("SqlOAuthStore.GetPreviousAccessData", "store.sql_oauth.get_previous_access_data.app_error", nil, err.Error(), http.StatusNotFound)
return nil, errors.Wrapf(err, "failed to get AccessData with clientId=%s and userId=%s", clientId, userId)
} }
return &accessData, nil return &accessData, nil
} }
func (as SqlOAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) { func (as SqlOAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, error) {
if err := accessData.IsValid(); err != nil { if err := accessData.IsValid(); err != nil {
return nil, err return nil, err
} }
if _, err := as.GetMaster().Exec("UPDATE OAuthAccessData SET Token = :Token, ExpiresAt = :ExpiresAt, RefreshToken = :RefreshToken WHERE ClientId = :ClientId AND UserID = :UserId", if _, err := as.GetMaster().Exec("UPDATE OAuthAccessData SET Token = :Token, ExpiresAt = :ExpiresAt, RefreshToken = :RefreshToken WHERE ClientId = :ClientId AND UserID = :UserId",
map[string]interface{}{"Token": accessData.Token, "ExpiresAt": accessData.ExpiresAt, "RefreshToken": accessData.RefreshToken, "ClientId": accessData.ClientId, "UserId": accessData.UserId}); err != nil { map[string]interface{}{"Token": accessData.Token, "ExpiresAt": accessData.ExpiresAt, "RefreshToken": accessData.RefreshToken, "ClientId": accessData.ClientId, "UserId": accessData.UserId}); err != nil {
return nil, model.NewAppError("SqlOAuthStore.Update", "store.sql_oauth.update_access_data.app_error", nil, return nil, errors.Wrapf(err, "failed to update OAuthAccessData with userId=%s and clientId=%s", accessData.UserId, accessData.ClientId)
"clientId="+accessData.ClientId+",userId="+accessData.UserId+", "+err.Error(), http.StatusInternalServerError)
} }
return accessData, nil return accessData, nil
} }
func (as SqlOAuthStore) RemoveAccessData(token string) *model.AppError { func (as SqlOAuthStore) RemoveAccessData(token string) error {
if _, err := as.GetMaster().Exec("DELETE FROM OAuthAccessData WHERE Token = :Token", map[string]interface{}{"Token": token}); err != nil { if _, err := as.GetMaster().Exec("DELETE FROM OAuthAccessData WHERE Token = :Token", map[string]interface{}{"Token": token}); err != nil {
return model.NewAppError("SqlOAuthStore.RemoveAccessData", "store.sql_oauth.remove_access_data.app_error", nil, "err="+err.Error(), http.StatusInternalServerError) return errors.Wrapf(err, "failed to delete OAuthAccessData with token=%s", token)
} }
return nil return nil
} }
func (as SqlOAuthStore) RemoveAllAccessData() *model.AppError { func (as SqlOAuthStore) RemoveAllAccessData() error {
if _, err := as.GetMaster().Exec("DELETE FROM OAuthAccessData", map[string]interface{}{}); err != nil { if _, err := as.GetMaster().Exec("DELETE FROM OAuthAccessData", map[string]interface{}{}); err != nil {
return model.NewAppError("SqlOAuthStore.RemoveAccessData", "store.sql_oauth.remove_access_data.app_error", nil, "err="+err.Error(), http.StatusInternalServerError) return errors.Wrap(err, "failed to delete OAuthAccessData")
} }
return nil return nil
} }
func (as SqlOAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, *model.AppError) { func (as SqlOAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, error) {
authData.PreSave() authData.PreSave()
if err := authData.IsValid(); err != nil { if err := authData.IsValid(); err != nil {
return nil, err return nil, err
} }
if err := as.GetMaster().Insert(authData); err != nil { if err := as.GetMaster().Insert(authData); err != nil {
return nil, model.NewAppError("SqlOAuthStore.SaveAuthData", "store.sql_oauth.save_auth_data.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrap(err, "failed to save AuthData")
} }
return authData, nil return authData, nil
} }
func (as SqlOAuthStore) GetAuthData(code string) (*model.AuthData, *model.AppError) { func (as SqlOAuthStore) GetAuthData(code string) (*model.AuthData, error) {
obj, err := as.GetReplica().Get(model.AuthData{}, code) obj, err := as.GetReplica().Get(model.AuthData{}, code)
if err != nil { if err != nil {
return nil, model.NewAppError("SqlOAuthStore.GetAuthData", "store.sql_oauth.get_auth_data.finding.app_error", nil, err.Error(), http.StatusInternalServerError) return nil, errors.Wrapf(err, "failed to get AuthData with code=%s", code)
} }
if obj == nil { if obj == nil {
return nil, model.NewAppError("SqlOAuthStore.GetAuthData", "store.sql_oauth.get_auth_data.find.app_error", nil, "", http.StatusNotFound) return nil, store.NewErrNotFound("AuthData", fmt.Sprintf("code=%s", code))
} }
return obj.(*model.AuthData), nil return obj.(*model.AuthData), nil
} }
func (as SqlOAuthStore) RemoveAuthData(code string) *model.AppError { func (as SqlOAuthStore) RemoveAuthData(code string) error {
_, err := as.GetMaster().Exec("DELETE FROM OAuthAuthData WHERE Code = :Code", map[string]interface{}{"Code": code}) _, err := as.GetMaster().Exec("DELETE FROM OAuthAuthData WHERE Code = :Code", map[string]interface{}{"Code": code})
if err != nil { if err != nil {
return model.NewAppError("SqlOAuthStore.RemoveAuthData", "store.sql_oauth.remove_auth_data.app_error", nil, "err="+err.Error(), http.StatusInternalServerError) return errors.Wrapf(err, "failed to delete AuthData with code=%s", code)
} }
return nil return nil
} }
func (as SqlOAuthStore) PermanentDeleteAuthDataByUser(userId string) *model.AppError { func (as SqlOAuthStore) PermanentDeleteAuthDataByUser(userId string) error {
_, err := as.GetMaster().Exec("DELETE FROM OAuthAccessData WHERE UserId = :UserId", map[string]interface{}{"UserId": userId}) _, err := as.GetMaster().Exec("DELETE FROM OAuthAccessData WHERE UserId = :UserId", map[string]interface{}{"UserId": userId})
if err != nil { if err != nil {
return model.NewAppError("SqlOAuthStore.RemoveAuthDataByUserId", "store.sql_oauth.permanent_delete_auth_data_by_user.app_error", nil, "err="+err.Error(), http.StatusInternalServerError) return errors.Wrapf(err, "failed to delete OAuthAccessData with userId=%s", userId)
} }
return nil return nil
} }
func (as SqlOAuthStore) deleteApp(transaction *gorp.Transaction, clientId string) *model.AppError { func (as SqlOAuthStore) deleteApp(transaction *gorp.Transaction, clientId string) error {
if _, err := transaction.Exec("DELETE FROM OAuthApps WHERE Id = :Id", map[string]interface{}{"Id": clientId}); err != nil { if _, err := transaction.Exec("DELETE FROM OAuthApps WHERE Id = :Id", map[string]interface{}{"Id": clientId}); err != nil {
return model.NewAppError("SqlOAuthStore.DeleteApp", "store.sql_oauth.delete_app.app_error", nil, "id="+clientId+", err="+err.Error(), http.StatusInternalServerError) return errors.Wrapf(err, "failed to delete OAuthApp with id=%s", clientId)
} }
return as.deleteOAuthAppSessions(transaction, clientId) return as.deleteOAuthAppSessions(transaction, clientId)
} }
func (as SqlOAuthStore) deleteOAuthAppSessions(transaction *gorp.Transaction, clientId string) *model.AppError { func (as SqlOAuthStore) deleteOAuthAppSessions(transaction *gorp.Transaction, clientId string) error {
query := "" query := ""
if as.DriverName() == model.DATABASE_DRIVER_POSTGRES { if as.DriverName() == model.DATABASE_DRIVER_POSTGRES {
@@ -303,28 +305,28 @@ func (as SqlOAuthStore) deleteOAuthAppSessions(transaction *gorp.Transaction, cl
} }
if _, err := transaction.Exec(query, map[string]interface{}{"Id": clientId}); err != nil { if _, err := transaction.Exec(query, map[string]interface{}{"Id": clientId}); err != nil {
return model.NewAppError("SqlOAuthStore.DeleteApp", "store.sql_oauth.delete_app.app_error", nil, "id="+clientId+", err="+err.Error(), http.StatusInternalServerError) return errors.Wrapf(err, "failed to delete Session with OAuthAccessData.Id=%s", clientId)
} }
return as.deleteOAuthTokens(transaction, clientId) return as.deleteOAuthTokens(transaction, clientId)
} }
func (as SqlOAuthStore) deleteOAuthTokens(transaction *gorp.Transaction, clientId string) *model.AppError { func (as SqlOAuthStore) deleteOAuthTokens(transaction *gorp.Transaction, clientId string) error {
if _, err := transaction.Exec("DELETE FROM OAuthAccessData WHERE ClientId = :Id", map[string]interface{}{"Id": clientId}); err != nil { if _, err := transaction.Exec("DELETE FROM OAuthAccessData WHERE ClientId = :Id", map[string]interface{}{"Id": clientId}); err != nil {
return model.NewAppError("SqlOAuthStore.DeleteApp", "store.sql_oauth.delete_app.app_error", nil, "id="+clientId+", err="+err.Error(), http.StatusInternalServerError) return errors.Wrapf(err, "failed to delete OAuthAccessData with id=%s", clientId)
} }
return as.deleteAppExtras(transaction, clientId) return as.deleteAppExtras(transaction, clientId)
} }
func (as SqlOAuthStore) deleteAppExtras(transaction *gorp.Transaction, clientId string) *model.AppError { func (as SqlOAuthStore) deleteAppExtras(transaction *gorp.Transaction, clientId string) error {
if _, err := transaction.Exec( if _, err := transaction.Exec(
`DELETE FROM `DELETE FROM
Preferences Preferences
WHERE WHERE
Category = :Category Category = :Category
AND Name = :Name`, map[string]interface{}{"Category": model.PREFERENCE_CATEGORY_AUTHORIZED_OAUTH_APP, "Name": clientId}); err != nil { AND Name = :Name`, map[string]interface{}{"Category": model.PREFERENCE_CATEGORY_AUTHORIZED_OAUTH_APP, "Name": clientId}); err != nil {
return model.NewAppError("SqlOAuthStore.DeleteApp", "store.sql_preference.delete.app_error", nil, err.Error(), http.StatusInternalServerError) return errors.Wrapf(err, "failed to delete Preferences with name=%s", clientId)
} }
return nil return nil

Просмотреть файл

@@ -412,25 +412,25 @@ type ComplianceStore interface {
} }
type OAuthStore interface { type OAuthStore interface {
SaveApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) SaveApp(app *model.OAuthApp) (*model.OAuthApp, error)
UpdateApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, error)
GetApp(id string) (*model.OAuthApp, *model.AppError) GetApp(id string) (*model.OAuthApp, error)
GetAppByUser(userId string, offset, limit int) ([]*model.OAuthApp, *model.AppError) GetAppByUser(userId string, offset, limit int) ([]*model.OAuthApp, error)
GetApps(offset, limit int) ([]*model.OAuthApp, *model.AppError) GetApps(offset, limit int) ([]*model.OAuthApp, error)
GetAuthorizedApps(userId string, offset, limit int) ([]*model.OAuthApp, *model.AppError) GetAuthorizedApps(userId string, offset, limit int) ([]*model.OAuthApp, error)
DeleteApp(id string) *model.AppError DeleteApp(id string) error
SaveAuthData(authData *model.AuthData) (*model.AuthData, *model.AppError) SaveAuthData(authData *model.AuthData) (*model.AuthData, error)
GetAuthData(code string) (*model.AuthData, *model.AppError) GetAuthData(code string) (*model.AuthData, error)
RemoveAuthData(code string) *model.AppError RemoveAuthData(code string) error
PermanentDeleteAuthDataByUser(userId string) *model.AppError PermanentDeleteAuthDataByUser(userId string) error
SaveAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) SaveAccessData(accessData *model.AccessData) (*model.AccessData, error)
UpdateAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, error)
GetAccessData(token string) (*model.AccessData, *model.AppError) GetAccessData(token string) (*model.AccessData, error)
GetAccessDataByUserForApp(userId, clientId string) ([]*model.AccessData, *model.AppError) GetAccessDataByUserForApp(userId, clientId string) ([]*model.AccessData, error)
GetAccessDataByRefreshToken(token string) (*model.AccessData, *model.AppError) GetAccessDataByRefreshToken(token string) (*model.AccessData, error)
GetPreviousAccessData(userId, clientId string) (*model.AccessData, *model.AppError) GetPreviousAccessData(userId, clientId string) (*model.AccessData, error)
RemoveAccessData(token string) *model.AppError RemoveAccessData(token string) error
RemoveAllAccessData() *model.AppError RemoveAllAccessData() error
} }
type SystemStore interface { type SystemStore interface {

Просмотреть файл

@@ -15,23 +15,21 @@ type OAuthStore struct {
} }
// DeleteApp provides a mock function with given fields: id // DeleteApp provides a mock function with given fields: id
func (_m *OAuthStore) DeleteApp(id string) *model.AppError { func (_m *OAuthStore) DeleteApp(id string) error {
ret := _m.Called(id) ret := _m.Called(id)
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok { if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(id) r0 = rf(id)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
} }
// GetAccessData provides a mock function with given fields: token // GetAccessData provides a mock function with given fields: token
func (_m *OAuthStore) GetAccessData(token string) (*model.AccessData, *model.AppError) { func (_m *OAuthStore) GetAccessData(token string) (*model.AccessData, error) {
ret := _m.Called(token) ret := _m.Called(token)
var r0 *model.AccessData var r0 *model.AccessData
@@ -43,20 +41,18 @@ func (_m *OAuthStore) GetAccessData(token string) (*model.AccessData, *model.App
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(token) r1 = rf(token)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetAccessDataByRefreshToken provides a mock function with given fields: token // GetAccessDataByRefreshToken provides a mock function with given fields: token
func (_m *OAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, *model.AppError) { func (_m *OAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, error) {
ret := _m.Called(token) ret := _m.Called(token)
var r0 *model.AccessData var r0 *model.AccessData
@@ -68,20 +64,18 @@ func (_m *OAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessDa
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(token) r1 = rf(token)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetAccessDataByUserForApp provides a mock function with given fields: userId, clientId // GetAccessDataByUserForApp provides a mock function with given fields: userId, clientId
func (_m *OAuthStore) GetAccessDataByUserForApp(userId string, clientId string) ([]*model.AccessData, *model.AppError) { func (_m *OAuthStore) GetAccessDataByUserForApp(userId string, clientId string) ([]*model.AccessData, error) {
ret := _m.Called(userId, clientId) ret := _m.Called(userId, clientId)
var r0 []*model.AccessData var r0 []*model.AccessData
@@ -93,20 +87,18 @@ func (_m *OAuthStore) GetAccessDataByUserForApp(userId string, clientId string)
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, clientId) r1 = rf(userId, clientId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetApp provides a mock function with given fields: id // GetApp provides a mock function with given fields: id
func (_m *OAuthStore) GetApp(id string) (*model.OAuthApp, *model.AppError) { func (_m *OAuthStore) GetApp(id string) (*model.OAuthApp, error) {
ret := _m.Called(id) ret := _m.Called(id)
var r0 *model.OAuthApp var r0 *model.OAuthApp
@@ -118,20 +110,18 @@ func (_m *OAuthStore) GetApp(id string) (*model.OAuthApp, *model.AppError) {
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(id) r1 = rf(id)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetAppByUser provides a mock function with given fields: userId, offset, limit // GetAppByUser provides a mock function with given fields: userId, offset, limit
func (_m *OAuthStore) GetAppByUser(userId string, offset int, limit int) ([]*model.OAuthApp, *model.AppError) { func (_m *OAuthStore) GetAppByUser(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
ret := _m.Called(userId, offset, limit) ret := _m.Called(userId, offset, limit)
var r0 []*model.OAuthApp var r0 []*model.OAuthApp
@@ -143,20 +133,18 @@ func (_m *OAuthStore) GetAppByUser(userId string, offset int, limit int) ([]*mod
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, int, int) error); ok {
r1 = rf(userId, offset, limit) r1 = rf(userId, offset, limit)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetApps provides a mock function with given fields: offset, limit // GetApps provides a mock function with given fields: offset, limit
func (_m *OAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, *model.AppError) { func (_m *OAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, error) {
ret := _m.Called(offset, limit) ret := _m.Called(offset, limit)
var r0 []*model.OAuthApp var r0 []*model.OAuthApp
@@ -168,20 +156,18 @@ func (_m *OAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, *model.
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(int, int) *model.AppError); ok { if rf, ok := ret.Get(1).(func(int, int) error); ok {
r1 = rf(offset, limit) r1 = rf(offset, limit)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetAuthData provides a mock function with given fields: code // GetAuthData provides a mock function with given fields: code
func (_m *OAuthStore) GetAuthData(code string) (*model.AuthData, *model.AppError) { func (_m *OAuthStore) GetAuthData(code string) (*model.AuthData, error) {
ret := _m.Called(code) ret := _m.Called(code)
var r0 *model.AuthData var r0 *model.AuthData
@@ -193,20 +179,18 @@ func (_m *OAuthStore) GetAuthData(code string) (*model.AuthData, *model.AppError
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(code) r1 = rf(code)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetAuthorizedApps provides a mock function with given fields: userId, offset, limit // GetAuthorizedApps provides a mock function with given fields: userId, offset, limit
func (_m *OAuthStore) GetAuthorizedApps(userId string, offset int, limit int) ([]*model.OAuthApp, *model.AppError) { func (_m *OAuthStore) GetAuthorizedApps(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
ret := _m.Called(userId, offset, limit) ret := _m.Called(userId, offset, limit)
var r0 []*model.OAuthApp var r0 []*model.OAuthApp
@@ -218,20 +202,18 @@ func (_m *OAuthStore) GetAuthorizedApps(userId string, offset int, limit int) ([
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, int, int) error); ok {
r1 = rf(userId, offset, limit) r1 = rf(userId, offset, limit)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// GetPreviousAccessData provides a mock function with given fields: userId, clientId // GetPreviousAccessData provides a mock function with given fields: userId, clientId
func (_m *OAuthStore) GetPreviousAccessData(userId string, clientId string) (*model.AccessData, *model.AppError) { func (_m *OAuthStore) GetPreviousAccessData(userId string, clientId string) (*model.AccessData, error) {
ret := _m.Called(userId, clientId) ret := _m.Called(userId, clientId)
var r0 *model.AccessData var r0 *model.AccessData
@@ -243,84 +225,74 @@ func (_m *OAuthStore) GetPreviousAccessData(userId string, clientId string) (*mo
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok { if rf, ok := ret.Get(1).(func(string, string) error); ok {
r1 = rf(userId, clientId) r1 = rf(userId, clientId)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// PermanentDeleteAuthDataByUser provides a mock function with given fields: userId // PermanentDeleteAuthDataByUser provides a mock function with given fields: userId
func (_m *OAuthStore) PermanentDeleteAuthDataByUser(userId string) *model.AppError { func (_m *OAuthStore) PermanentDeleteAuthDataByUser(userId string) error {
ret := _m.Called(userId) ret := _m.Called(userId)
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok { if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(userId) r0 = rf(userId)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
} }
// RemoveAccessData provides a mock function with given fields: token // RemoveAccessData provides a mock function with given fields: token
func (_m *OAuthStore) RemoveAccessData(token string) *model.AppError { func (_m *OAuthStore) RemoveAccessData(token string) error {
ret := _m.Called(token) ret := _m.Called(token)
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok { if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(token) r0 = rf(token)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
} }
// RemoveAllAccessData provides a mock function with given fields: // RemoveAllAccessData provides a mock function with given fields:
func (_m *OAuthStore) RemoveAllAccessData() *model.AppError { func (_m *OAuthStore) RemoveAllAccessData() error {
ret := _m.Called() ret := _m.Called()
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func() *model.AppError); ok { if rf, ok := ret.Get(0).(func() error); ok {
r0 = rf() r0 = rf()
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
} }
// RemoveAuthData provides a mock function with given fields: code // RemoveAuthData provides a mock function with given fields: code
func (_m *OAuthStore) RemoveAuthData(code string) *model.AppError { func (_m *OAuthStore) RemoveAuthData(code string) error {
ret := _m.Called(code) ret := _m.Called(code)
var r0 *model.AppError var r0 error
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok { if rf, ok := ret.Get(0).(func(string) error); ok {
r0 = rf(code) r0 = rf(code)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Error(0)
r0 = ret.Get(0).(*model.AppError)
}
} }
return r0 return r0
} }
// SaveAccessData provides a mock function with given fields: accessData // SaveAccessData provides a mock function with given fields: accessData
func (_m *OAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) { func (_m *OAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, error) {
ret := _m.Called(accessData) ret := _m.Called(accessData)
var r0 *model.AccessData var r0 *model.AccessData
@@ -332,20 +304,18 @@ func (_m *OAuthStore) SaveAccessData(accessData *model.AccessData) (*model.Acces
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(*model.AccessData) *model.AppError); ok { if rf, ok := ret.Get(1).(func(*model.AccessData) error); ok {
r1 = rf(accessData) r1 = rf(accessData)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// SaveApp provides a mock function with given fields: app // SaveApp provides a mock function with given fields: app
func (_m *OAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) { func (_m *OAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, error) {
ret := _m.Called(app) ret := _m.Called(app)
var r0 *model.OAuthApp var r0 *model.OAuthApp
@@ -357,20 +327,18 @@ func (_m *OAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppE
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(*model.OAuthApp) *model.AppError); ok { if rf, ok := ret.Get(1).(func(*model.OAuthApp) error); ok {
r1 = rf(app) r1 = rf(app)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// SaveAuthData provides a mock function with given fields: authData // SaveAuthData provides a mock function with given fields: authData
func (_m *OAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, *model.AppError) { func (_m *OAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, error) {
ret := _m.Called(authData) ret := _m.Called(authData)
var r0 *model.AuthData var r0 *model.AuthData
@@ -382,20 +350,18 @@ func (_m *OAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, *
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(*model.AuthData) *model.AppError); ok { if rf, ok := ret.Get(1).(func(*model.AuthData) error); ok {
r1 = rf(authData) r1 = rf(authData)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// UpdateAccessData provides a mock function with given fields: accessData // UpdateAccessData provides a mock function with given fields: accessData
func (_m *OAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) { func (_m *OAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, error) {
ret := _m.Called(accessData) ret := _m.Called(accessData)
var r0 *model.AccessData var r0 *model.AccessData
@@ -407,20 +373,18 @@ func (_m *OAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.Acc
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(*model.AccessData) *model.AppError); ok { if rf, ok := ret.Get(1).(func(*model.AccessData) error); ok {
r1 = rf(accessData) r1 = rf(accessData)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1
} }
// UpdateApp provides a mock function with given fields: app // UpdateApp provides a mock function with given fields: app
func (_m *OAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) { func (_m *OAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, error) {
ret := _m.Called(app) ret := _m.Called(app)
var r0 *model.OAuthApp var r0 *model.OAuthApp
@@ -432,13 +396,11 @@ func (_m *OAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, *model.Ap
} }
} }
var r1 *model.AppError var r1 error
if rf, ok := ret.Get(1).(func(*model.OAuthApp) *model.AppError); ok { if rf, ok := ret.Get(1).(func(*model.OAuthApp) error); ok {
r1 = rf(app) r1 = rf(app)
} else { } else {
if ret.Get(1) != nil { r1 = ret.Error(1)
r1 = ret.Get(1).(*model.AppError)
}
} }
return r0, r1 return r0, r1

Просмотреть файл

@@ -20,6 +20,7 @@ func TestOAuthStore(t *testing.T, ss store.Store) {
t.Run("OAuthUpdateAccessData", func(t *testing.T) { testOAuthUpdateAccessData(t, ss) }) t.Run("OAuthUpdateAccessData", func(t *testing.T) { testOAuthUpdateAccessData(t, ss) })
t.Run("GetAccessData", func(t *testing.T) { testOAuthStoreGetAccessData(t, ss) }) t.Run("GetAccessData", func(t *testing.T) { testOAuthStoreGetAccessData(t, ss) })
t.Run("RemoveAccessData", func(t *testing.T) { testOAuthStoreRemoveAccessData(t, ss) }) t.Run("RemoveAccessData", func(t *testing.T) { testOAuthStoreRemoveAccessData(t, ss) })
t.Run("RemoveAllAccessData", func(t *testing.T) { testOAuthStoreRemoveAllAccessData(t, ss) })
t.Run("SaveAuthData", func(t *testing.T) { testOAuthStoreSaveAuthData(t, ss) }) t.Run("SaveAuthData", func(t *testing.T) { testOAuthStoreSaveAuthData(t, ss) })
t.Run("GetAuthData", func(t *testing.T) { testOAuthStoreGetAuthData(t, ss) }) t.Run("GetAuthData", func(t *testing.T) { testOAuthStoreGetAuthData(t, ss) })
t.Run("RemoveAuthData", func(t *testing.T) { testOAuthStoreRemoveAuthData(t, ss) }) t.Run("RemoveAuthData", func(t *testing.T) { testOAuthStoreRemoveAuthData(t, ss) })
@@ -213,7 +214,7 @@ func testOAuthStoreRemoveAccessData(t *testing.T, ss store.Store) {
require.Nil(t, result, "did not delete access token") require.Nil(t, result, "did not delete access token")
} }
func TestOAuthStoreRemoveAllAccessData(t *testing.T, ss store.Store) { func testOAuthStoreRemoveAllAccessData(t *testing.T, ss store.Store) {
a1 := model.AccessData{} a1 := model.AccessData{}
a1.ClientId = model.NewId() a1.ClientId = model.NewId()
a1.UserId = model.NewId() a1.UserId = model.NewId()

Просмотреть файл

@@ -3806,7 +3806,7 @@ func (s *TimerLayerLinkMetadataStore) Save(linkMetadata *model.LinkMetadata) (*m
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) DeleteApp(id string) *model.AppError { func (s *TimerLayerOAuthStore) DeleteApp(id string) error {
start := timemodule.Now() start := timemodule.Now()
resultVar0 := s.OAuthStore.DeleteApp(id) resultVar0 := s.OAuthStore.DeleteApp(id)
@@ -3822,7 +3822,7 @@ func (s *TimerLayerOAuthStore) DeleteApp(id string) *model.AppError {
return resultVar0 return resultVar0
} }
func (s *TimerLayerOAuthStore) GetAccessData(token string) (*model.AccessData, *model.AppError) { func (s *TimerLayerOAuthStore) GetAccessData(token string) (*model.AccessData, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.GetAccessData(token) resultVar0, resultVar1 := s.OAuthStore.GetAccessData(token)
@@ -3838,7 +3838,7 @@ func (s *TimerLayerOAuthStore) GetAccessData(token string) (*model.AccessData, *
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, *model.AppError) { func (s *TimerLayerOAuthStore) GetAccessDataByRefreshToken(token string) (*model.AccessData, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.GetAccessDataByRefreshToken(token) resultVar0, resultVar1 := s.OAuthStore.GetAccessDataByRefreshToken(token)
@@ -3854,7 +3854,7 @@ func (s *TimerLayerOAuthStore) GetAccessDataByRefreshToken(token string) (*model
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) GetAccessDataByUserForApp(userId string, clientId string) ([]*model.AccessData, *model.AppError) { func (s *TimerLayerOAuthStore) GetAccessDataByUserForApp(userId string, clientId string) ([]*model.AccessData, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.GetAccessDataByUserForApp(userId, clientId) resultVar0, resultVar1 := s.OAuthStore.GetAccessDataByUserForApp(userId, clientId)
@@ -3870,7 +3870,7 @@ func (s *TimerLayerOAuthStore) GetAccessDataByUserForApp(userId string, clientId
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) GetApp(id string) (*model.OAuthApp, *model.AppError) { func (s *TimerLayerOAuthStore) GetApp(id string) (*model.OAuthApp, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.GetApp(id) resultVar0, resultVar1 := s.OAuthStore.GetApp(id)
@@ -3886,7 +3886,7 @@ func (s *TimerLayerOAuthStore) GetApp(id string) (*model.OAuthApp, *model.AppErr
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) GetAppByUser(userId string, offset int, limit int) ([]*model.OAuthApp, *model.AppError) { func (s *TimerLayerOAuthStore) GetAppByUser(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.GetAppByUser(userId, offset, limit) resultVar0, resultVar1 := s.OAuthStore.GetAppByUser(userId, offset, limit)
@@ -3902,7 +3902,7 @@ func (s *TimerLayerOAuthStore) GetAppByUser(userId string, offset int, limit int
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, *model.AppError) { func (s *TimerLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.GetApps(offset, limit) resultVar0, resultVar1 := s.OAuthStore.GetApps(offset, limit)
@@ -3918,7 +3918,7 @@ func (s *TimerLayerOAuthStore) GetApps(offset int, limit int) ([]*model.OAuthApp
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) GetAuthData(code string) (*model.AuthData, *model.AppError) { func (s *TimerLayerOAuthStore) GetAuthData(code string) (*model.AuthData, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.GetAuthData(code) resultVar0, resultVar1 := s.OAuthStore.GetAuthData(code)
@@ -3934,7 +3934,7 @@ func (s *TimerLayerOAuthStore) GetAuthData(code string) (*model.AuthData, *model
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) GetAuthorizedApps(userId string, offset int, limit int) ([]*model.OAuthApp, *model.AppError) { func (s *TimerLayerOAuthStore) GetAuthorizedApps(userId string, offset int, limit int) ([]*model.OAuthApp, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.GetAuthorizedApps(userId, offset, limit) resultVar0, resultVar1 := s.OAuthStore.GetAuthorizedApps(userId, offset, limit)
@@ -3950,7 +3950,7 @@ func (s *TimerLayerOAuthStore) GetAuthorizedApps(userId string, offset int, limi
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) GetPreviousAccessData(userId string, clientId string) (*model.AccessData, *model.AppError) { func (s *TimerLayerOAuthStore) GetPreviousAccessData(userId string, clientId string) (*model.AccessData, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.GetPreviousAccessData(userId, clientId) resultVar0, resultVar1 := s.OAuthStore.GetPreviousAccessData(userId, clientId)
@@ -3966,7 +3966,7 @@ func (s *TimerLayerOAuthStore) GetPreviousAccessData(userId string, clientId str
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) PermanentDeleteAuthDataByUser(userId string) *model.AppError { func (s *TimerLayerOAuthStore) PermanentDeleteAuthDataByUser(userId string) error {
start := timemodule.Now() start := timemodule.Now()
resultVar0 := s.OAuthStore.PermanentDeleteAuthDataByUser(userId) resultVar0 := s.OAuthStore.PermanentDeleteAuthDataByUser(userId)
@@ -3982,7 +3982,7 @@ func (s *TimerLayerOAuthStore) PermanentDeleteAuthDataByUser(userId string) *mod
return resultVar0 return resultVar0
} }
func (s *TimerLayerOAuthStore) RemoveAccessData(token string) *model.AppError { func (s *TimerLayerOAuthStore) RemoveAccessData(token string) error {
start := timemodule.Now() start := timemodule.Now()
resultVar0 := s.OAuthStore.RemoveAccessData(token) resultVar0 := s.OAuthStore.RemoveAccessData(token)
@@ -3998,7 +3998,7 @@ func (s *TimerLayerOAuthStore) RemoveAccessData(token string) *model.AppError {
return resultVar0 return resultVar0
} }
func (s *TimerLayerOAuthStore) RemoveAllAccessData() *model.AppError { func (s *TimerLayerOAuthStore) RemoveAllAccessData() error {
start := timemodule.Now() start := timemodule.Now()
resultVar0 := s.OAuthStore.RemoveAllAccessData() resultVar0 := s.OAuthStore.RemoveAllAccessData()
@@ -4014,7 +4014,7 @@ func (s *TimerLayerOAuthStore) RemoveAllAccessData() *model.AppError {
return resultVar0 return resultVar0
} }
func (s *TimerLayerOAuthStore) RemoveAuthData(code string) *model.AppError { func (s *TimerLayerOAuthStore) RemoveAuthData(code string) error {
start := timemodule.Now() start := timemodule.Now()
resultVar0 := s.OAuthStore.RemoveAuthData(code) resultVar0 := s.OAuthStore.RemoveAuthData(code)
@@ -4030,7 +4030,7 @@ func (s *TimerLayerOAuthStore) RemoveAuthData(code string) *model.AppError {
return resultVar0 return resultVar0
} }
func (s *TimerLayerOAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) { func (s *TimerLayerOAuthStore) SaveAccessData(accessData *model.AccessData) (*model.AccessData, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.SaveAccessData(accessData) resultVar0, resultVar1 := s.OAuthStore.SaveAccessData(accessData)
@@ -4046,7 +4046,7 @@ func (s *TimerLayerOAuthStore) SaveAccessData(accessData *model.AccessData) (*mo
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) { func (s *TimerLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.SaveApp(app) resultVar0, resultVar1 := s.OAuthStore.SaveApp(app)
@@ -4062,7 +4062,7 @@ func (s *TimerLayerOAuthStore) SaveApp(app *model.OAuthApp) (*model.OAuthApp, *m
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, *model.AppError) { func (s *TimerLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*model.AuthData, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.SaveAuthData(authData) resultVar0, resultVar1 := s.OAuthStore.SaveAuthData(authData)
@@ -4078,7 +4078,7 @@ func (s *TimerLayerOAuthStore) SaveAuthData(authData *model.AuthData) (*model.Au
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, *model.AppError) { func (s *TimerLayerOAuthStore) UpdateAccessData(accessData *model.AccessData) (*model.AccessData, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.UpdateAccessData(accessData) resultVar0, resultVar1 := s.OAuthStore.UpdateAccessData(accessData)
@@ -4094,7 +4094,7 @@ func (s *TimerLayerOAuthStore) UpdateAccessData(accessData *model.AccessData) (*
return resultVar0, resultVar1 return resultVar0, resultVar1
} }
func (s *TimerLayerOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, *model.AppError) { func (s *TimerLayerOAuthStore) UpdateApp(app *model.OAuthApp) (*model.OAuthApp, error) {
start := timemodule.Now() start := timemodule.Now()
resultVar0, resultVar1 := s.OAuthStore.UpdateApp(app) resultVar0, resultVar1 := s.OAuthStore.UpdateApp(app)

Просмотреть файл

@@ -336,8 +336,8 @@ func TestOAuthAccessToken(t *testing.T) {
require.Nil(t, err) require.Nil(t, err)
authData := &model.AuthData{ClientId: oauthApp.Id, RedirectUri: oauthApp.CallbackUrls[0], UserId: th.BasicUser.Id, Code: model.NewId(), ExpiresIn: -1} authData := &model.AuthData{ClientId: oauthApp.Id, RedirectUri: oauthApp.CallbackUrls[0], UserId: th.BasicUser.Id, Code: model.NewId(), ExpiresIn: -1}
_, err = th.App.Srv().Store.OAuth().SaveAuthData(authData) _, nErr := th.App.Srv().Store.OAuth().SaveAuthData(authData)
require.Nil(t, err) require.Nil(t, nErr)
data.Set("grant_type", model.ACCESS_TOKEN_GRANT_TYPE) data.Set("grant_type", model.ACCESS_TOKEN_GRANT_TYPE)
data.Set("client_id", oauthApp.Id) data.Set("client_id", oauthApp.Id)