diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-01-13 15:17:50 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-01-13 15:17:50 -0500 |
commit | 0e2b321e6f5ab5983bc3428aa455dac7012c36ee (patch) | |
tree | c3919a284cf13ddcb66a6f482b1c9bbd9f34fc9b /app/oauth.go | |
parent | 97558f6a6ec4c53fa69035fb430ead209d9c222d (diff) | |
download | chat-0e2b321e6f5ab5983bc3428aa455dac7012c36ee.tar.gz chat-0e2b321e6f5ab5983bc3428aa455dac7012c36ee.tar.bz2 chat-0e2b321e6f5ab5983bc3428aa455dac7012c36ee.zip |
Refactor and migrate more functions out of api into app package (#5063)
Diffstat (limited to 'app/oauth.go')
-rw-r--r-- | app/oauth.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/oauth.go b/app/oauth.go new file mode 100644 index 000000000..862897b24 --- /dev/null +++ b/app/oauth.go @@ -0,0 +1,34 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package app + +import ( + "github.com/mattermost/platform/model" +) + +func RevokeAccessToken(token string) *model.AppError { + + session, _ := GetSession(token) + schan := Srv.Store.Session().Remove(token) + + if result := <-Srv.Store.OAuth().GetAccessData(token); result.Err != nil { + return model.NewLocAppError("RevokeAccessToken", "api.oauth.revoke_access_token.get.app_error", nil, "") + } + + tchan := Srv.Store.OAuth().RemoveAccessData(token) + + if result := <-tchan; result.Err != nil { + return model.NewLocAppError("RevokeAccessToken", "api.oauth.revoke_access_token.del_token.app_error", nil, "") + } + + if result := <-schan; result.Err != nil { + return model.NewLocAppError("RevokeAccessToken", "api.oauth.revoke_access_token.del_session.app_error", nil, "") + } + + if session != nil { + RemoveAllSessionsForUserId(session.UserId) + } + + return nil +} |