summaryrefslogtreecommitdiffstats
path: root/store/sql_oauth_store.go
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-08-23 19:06:17 -0300
committerJoram Wilander <jwawilander@gmail.com>2016-08-23 18:06:17 -0400
commit9ab5a7996247c98ed6267b638e1b313e7c4eb8ff (patch)
tree95579883cd48370ee48259b2bec02b124df2f200 /store/sql_oauth_store.go
parente406a92fbbfe36765ab66d9879a9c94546c7c281 (diff)
downloadchat-9ab5a7996247c98ed6267b638e1b313e7c4eb8ff.tar.gz
chat-9ab5a7996247c98ed6267b638e1b313e7c4eb8ff.tar.bz2
chat-9ab5a7996247c98ed6267b638e1b313e7c4eb8ff.zip
PLT-3745 - Deauthorize OAuth Apps (#3852)
* Deauthorize OAuth APIs * Deautorize OAuth Apps Account Settings * Fix typo in client method * Fix issues found by PM * Show help text only when there is at least one authorized app
Diffstat (limited to 'store/sql_oauth_store.go')
-rw-r--r--store/sql_oauth_store.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/store/sql_oauth_store.go b/store/sql_oauth_store.go
index 6db54bd4a..0ee9f1ad1 100644
--- a/store/sql_oauth_store.go
+++ b/store/sql_oauth_store.go
@@ -211,6 +211,29 @@ func (as SqlOAuthStore) GetApps() StoreChannel {
return storeChannel
}
+func (as SqlOAuthStore) GetAuthorizedApps(userId string) StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ var apps []*model.OAuthApp
+
+ if _, err := as.GetReplica().Select(&apps,
+ `SELECT o.* FROM OAuthApps AS o INNER JOIN
+ Preferences AS p ON p.Name=o.Id AND p.UserId=:UserId`, map[string]interface{}{"UserId": userId}); err != nil {
+ result.Err = model.NewLocAppError("SqlOAuthStore.GetAuthorizedApps", "store.sql_oauth.get_apps.find.app_error", nil, "err="+err.Error())
+ }
+
+ result.Data = apps
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
func (as SqlOAuthStore) DeleteApp(id string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -294,6 +317,33 @@ func (as SqlOAuthStore) GetAccessData(token string) StoreChannel {
return storeChannel
}
+func (as SqlOAuthStore) GetAccessDataByUserForApp(userId, clientId string) StoreChannel {
+
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ var accessData []*model.AccessData
+
+ if _, err := as.GetReplica().Select(&accessData,
+ "SELECT * FROM OAuthAccessData WHERE UserId = :UserId AND ClientId = :ClientId",
+ map[string]interface{}{"UserId": userId, "ClientId": clientId}); err != nil {
+ result.Err = model.NewLocAppError("SqlOAuthStore.GetAccessDataByUserForApp",
+ "store.sql_oauth.get_access_data_by_user_for_app.app_error", nil,
+ "user_id="+userId+" client_id="+clientId)
+ } else {
+ result.Data = accessData
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+
+ }()
+
+ return storeChannel
+}
+
func (as SqlOAuthStore) GetAccessDataByRefreshToken(token string) StoreChannel {
storeChannel := make(StoreChannel)