[MM-57942] Fix a panic on password is too long (#27449)
* return error from bcrypt, handle gracefully; remove dead code * linting * linting * i18n * fix test * fill out translations
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5d2bf1ea1c
Коммит
cc5e87ae24
@@ -112,7 +112,9 @@ func (us SqlUserStore) Save(rctx request.CTX, user *model.User) (*model.User, er
|
||||
return nil, store.NewErrInvalidInput("User", "id", user.Id)
|
||||
}
|
||||
|
||||
user.PreSave()
|
||||
if err := user.PreSave(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := user.IsValid(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -2294,7 +2296,11 @@ func testUserStoreUpdatePassword(t *testing.T, rctx request.CTX, ss store.Store)
|
||||
_, nErr := ss.Team().SaveMember(rctx, &model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
hashedPassword := model.HashPassword("newpwd")
|
||||
_, err = model.HashPassword(strings.Repeat("1234567890", 8))
|
||||
require.ErrorIs(t, err, bcrypt.ErrPasswordTooLong)
|
||||
|
||||
hashedPassword, err := model.HashPassword("newpwd")
|
||||
require.NoError(t, err)
|
||||
|
||||
err = ss.User().UpdatePassword(u1.Id, hashedPassword)
|
||||
require.NoError(t, err)
|
||||
|
||||
Ссылка в новой задаче
Block a user