Minor fix
Этот коммит содержится в:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user