summaryrefslogtreecommitdiffstats
path: root/store/sql_oauth_store.go
diff options
context:
space:
mode:
Diffstat (limited to 'store/sql_oauth_store.go')
-rw-r--r--store/sql_oauth_store.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/store/sql_oauth_store.go b/store/sql_oauth_store.go
index 8637055ae..2e6fe2655 100644
--- a/store/sql_oauth_store.go
+++ b/store/sql_oauth_store.go
@@ -9,6 +9,7 @@ import (
"github.com/mattermost/gorp"
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
)
type SqlOAuthStore struct {
@@ -521,6 +522,24 @@ func (as SqlOAuthStore) deleteApp(transaction *gorp.Transaction, clientId string
return result
}
+ return as.deleteOAuthAppSessions(transaction, clientId)
+}
+
+func (as SqlOAuthStore) deleteOAuthAppSessions(transaction *gorp.Transaction, clientId string) StoreResult {
+ result := StoreResult{}
+
+ query := ""
+ if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
+ query = "DELETE FROM Sessions s USING OAuthAccessData o WHERE o.Token = s.Token AND o.ClientId = :Id"
+ } else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
+ query = "DELETE s.* FROM Sessions s INNER JOIN OAuthAccessData o ON o.Token = s.Token WHERE o.ClientId = :Id"
+ }
+
+ if _, err := transaction.Exec(query, map[string]interface{}{"Id": clientId}); err != nil {
+ result.Err = model.NewLocAppError("SqlOAuthStore.DeleteApp", "store.sql_oauth.delete_app.app_error", nil, "id="+clientId+", err="+err.Error())
+ return result
+ }
+
return as.deleteOAuthTokens(transaction, clientId)
}