diff options
author | Wim <wim@42.be> | 2016-08-15 18:47:31 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2016-08-15 18:47:31 +0200 |
commit | 24defcb970838133eb82f4fbbc516630fb81cae6 (patch) | |
tree | de88bd0761b08ee35d8f2ddbcb133f7899b4264d /vendor/github.com/mattermost/platform/model/access.go | |
parent | a1a11a88b334a4deb78915336def0113eec9738b (diff) | |
download | matterbridge-msglm-24defcb970838133eb82f4fbbc516630fb81cae6.tar.gz matterbridge-msglm-24defcb970838133eb82f4fbbc516630fb81cae6.tar.bz2 matterbridge-msglm-24defcb970838133eb82f4fbbc516630fb81cae6.zip |
Sync with mattermost 3.3.0
Diffstat (limited to 'vendor/github.com/mattermost/platform/model/access.go')
-rw-r--r-- | vendor/github.com/mattermost/platform/model/access.go | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/vendor/github.com/mattermost/platform/model/access.go b/vendor/github.com/mattermost/platform/model/access.go index 877b3c4f..85417fce 100644 --- a/vendor/github.com/mattermost/platform/model/access.go +++ b/vendor/github.com/mattermost/platform/model/access.go @@ -15,10 +15,12 @@ const ( ) type AccessData struct { - AuthCode string `json:"auth_code"` + ClientId string `json:"client_id"` + UserId string `json:"user_id"` Token string `json:"token"` RefreshToken string `json:"refresh_token"` RedirectUri string `json:"redirect_uri"` + ExpiresAt int64 `json:"expires_at"` } type AccessResponse struct { @@ -33,8 +35,12 @@ type AccessResponse struct { // correctly. func (ad *AccessData) IsValid() *AppError { - if len(ad.AuthCode) == 0 || len(ad.AuthCode) > 128 { - return NewLocAppError("AccessData.IsValid", "model.access.is_valid.auth_code.app_error", nil, "") + if len(ad.ClientId) == 0 || len(ad.ClientId) > 26 { + return NewLocAppError("AccessData.IsValid", "model.access.is_valid.client_id.app_error", nil, "") + } + + if len(ad.UserId) == 0 || len(ad.UserId) > 26 { + return NewLocAppError("AccessData.IsValid", "model.access.is_valid.user_id.app_error", nil, "") } if len(ad.Token) != 26 { @@ -52,6 +58,19 @@ func (ad *AccessData) IsValid() *AppError { return nil } +func (me *AccessData) IsExpired() bool { + + if me.ExpiresAt <= 0 { + return false + } + + if GetMillis() > me.ExpiresAt { + return true + } + + return false +} + func (ad *AccessData) ToJson() string { b, err := json.Marshal(ad) if err != nil { |