summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2017-07-12 16:58:51 -0400
committerJoramWilander <jwawilander@gmail.com>2017-07-12 16:58:51 -0400
commit259ad46f30d0fac2f7c5c14f3b76b2170f7e90c7 (patch)
tree627c5a1d3c40f1391edea4be2881e189ba4ef934 /store
parent96d7783d36986a8300d173eef44976f2425f1a7d (diff)
downloadchat-259ad46f30d0fac2f7c5c14f3b76b2170f7e90c7.tar.gz
chat-259ad46f30d0fac2f7c5c14f3b76b2170f7e90c7.tar.bz2
chat-259ad46f30d0fac2f7c5c14f3b76b2170f7e90c7.zip
Minor fix
Diffstat (limited to 'store')
-rw-r--r--store/sql_oauth_store.go11
-rw-r--r--store/sql_oauth_store_test.go24
2 files changed, 35 insertions, 0 deletions
diff --git a/store/sql_oauth_store.go b/store/sql_oauth_store.go
index 8637055ae..8e23a8cb2 100644
--- a/store/sql_oauth_store.go
+++ b/store/sql_oauth_store.go
@@ -521,6 +521,17 @@ 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{}
+
+ if _, err := transaction.Exec("DELETE s.* FROM Sessions s INNER JOIN OAuthAccessData o ON o.Token = s.Token WHERE o.ClientId = :Id", 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)
}
diff --git a/store/sql_oauth_store_test.go b/store/sql_oauth_store_test.go
index 8c707562f..4dc09b830 100644
--- a/store/sql_oauth_store_test.go
+++ b/store/sql_oauth_store_test.go
@@ -414,7 +414,31 @@ func TestOAuthStoreDeleteApp(t *testing.T) {
t.Fatal(err)
}
+ s1 := model.Session{}
+ s1.UserId = model.NewId()
+ s1.Token = model.NewId()
+ s1.IsOAuth = true
+
+ Must(store.Session().Save(&s1))
+
+ ad1 := model.AccessData{}
+ ad1.ClientId = a1.Id
+ ad1.UserId = a1.CreatorId
+ ad1.Token = s1.Token
+ ad1.RefreshToken = model.NewId()
+ ad1.RedirectUri = "http://example.com"
+
+ Must(store.OAuth().SaveAccessData(&ad1))
+
if err := (<-store.OAuth().DeleteApp(a1.Id)).Err; err != nil {
t.Fatal(err)
}
+
+ if err := (<-store.Session().Get(s1.Token)).Err; err == nil {
+ t.Fatal("should error - session should be deleted")
+ }
+
+ if err := (<-store.OAuth().GetAccessData(s1.Token)).Err; err == nil {
+ t.Fatal("should error - access data should be deleted")
+ }
}