summaryrefslogtreecommitdiffstats
path: root/app/oauth.go
diff options
context:
space:
mode:
authorn1aba <n1aba.github@gmail.com>2017-09-18 14:40:41 +0300
committerJoram Wilander <jwawilander@gmail.com>2017-09-18 07:40:41 -0400
commit5a855e1ca1c1403ea63e4812d33b2b10a6a0fcf7 (patch)
treecfa615903bc4307e88584cd46001cb7c4f6746dd /app/oauth.go
parent7243aa6751c266ecd342a41cbef390c71a962425 (diff)
downloadchat-5a855e1ca1c1403ea63e4812d33b2b10a6a0fcf7.tar.gz
chat-5a855e1ca1c1403ea63e4812d33b2b10a6a0fcf7.tar.bz2
chat-5a855e1ca1c1403ea63e4812d33b2b10a6a0fcf7.zip
Implement update OAuthApp endpoint for APIv4, add test (#7413)
Diffstat (limited to 'app/oauth.go')
-rw-r--r--app/oauth.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/oauth.go b/app/oauth.go
index a0fcfd609..2b45409a6 100644
--- a/app/oauth.go
+++ b/app/oauth.go
@@ -53,6 +53,23 @@ func (a *App) GetOAuthApp(appId string) (*model.OAuthApp, *model.AppError) {
}
}
+func (a *App) UpdateOauthApp(oldApp, updatedApp *model.OAuthApp) (*model.OAuthApp, *model.AppError) {
+ if !utils.Cfg.ServiceSettings.EnableOAuthServiceProvider {
+ return nil, model.NewAppError("UpdateOauthApp", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)
+ }
+
+ updatedApp.Id = oldApp.Id
+ updatedApp.CreatorId = oldApp.CreatorId
+ updatedApp.CreateAt = oldApp.CreateAt
+ updatedApp.ClientSecret = oldApp.ClientSecret
+
+ if result := <-a.Srv.Store.OAuth().UpdateApp(updatedApp); result.Err != nil {
+ return nil, result.Err
+ } else {
+ return result.Data.([2]*model.OAuthApp)[0], nil
+ }
+}
+
func (a *App) DeleteOAuthApp(appId string) *model.AppError {
if !utils.Cfg.ServiceSettings.EnableOAuthServiceProvider {
return model.NewAppError("DeleteOAuthApp", "api.oauth.allow_oauth.turn_off.app_error", nil, "", http.StatusNotImplemented)