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
Этот коммит содержится в:
enahum
2016-08-23 19:06:17 -03:00
коммит произвёл Joram Wilander
родитель e406a92fbb
Коммит 9ab5a79962
12 изменённых файлов: 532 добавлений и 41 удалений

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

@@ -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)