Fix bots being unable to post when personal access tokens are disabled. (#11105)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
729a7ac0ac
Коммит
1ca421472f
@@ -262,10 +262,6 @@ func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAc
|
||||
}
|
||||
|
||||
func (a *App) createSessionForUserAccessToken(tokenString string) (*model.Session, *model.AppError) {
|
||||
if !*a.Config().ServiceSettings.EnableUserAccessTokens {
|
||||
return nil, model.NewAppError("createSessionForUserAccessToken", "app.user_access_token.invalid_or_missing", nil, "EnableUserAccessTokens=false", http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
var token *model.UserAccessToken
|
||||
result := <-a.Srv.Store.UserAccessToken().GetByToken(tokenString)
|
||||
if result.Err != nil {
|
||||
@@ -282,6 +278,10 @@ func (a *App) createSessionForUserAccessToken(tokenString string) (*model.Sessio
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !*a.Config().ServiceSettings.EnableUserAccessTokens && !user.IsBot {
|
||||
return nil, model.NewAppError("createSessionForUserAccessToken", "app.user_access_token.invalid_or_missing", nil, "EnableUserAccessTokens=false", http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
if user.DeleteAt != 0 {
|
||||
return nil, model.NewAppError("createSessionForUserAccessToken", "app.user_access_token.invalid_or_missing", nil, "inactive_user_id="+user.Id, http.StatusUnauthorized)
|
||||
}
|
||||
@@ -295,6 +295,9 @@ func (a *App) createSessionForUserAccessToken(tokenString string) (*model.Sessio
|
||||
|
||||
session.AddProp(model.SESSION_PROP_USER_ACCESS_TOKEN_ID, token.Id)
|
||||
session.AddProp(model.SESSION_PROP_TYPE, model.SESSION_TYPE_USER_ACCESS_TOKEN)
|
||||
if user.IsBot {
|
||||
session.AddProp(model.SESSION_PROP_IS_BOT, model.SESSION_PROP_IS_BOT_VALUE)
|
||||
}
|
||||
session.SetExpireInDays(model.SESSION_USER_ACCESS_TOKEN_EXPIRY)
|
||||
|
||||
session, err = a.Srv.Store.Session().Save(session)
|
||||
|
||||
Ссылка в новой задаче
Block a user