mirror of
https://github.com/go-gitea/gitea
synced 2025-07-19 00:38:36 +00:00
Fix random string generator (#384)
* Remove unused custom-alphabet feature of random string generator Fix random string generator Random string generator should return error if it fails to read random data via crypto/rand * Fixes variable (un)initialization mixed assign Update test GetRandomString
This commit is contained in:
committed by
Thomas Boerger
parent
952587dbae
commit
380e32e129
@@ -532,7 +532,7 @@ func IsUserExist(uid int64, name string) (bool, error) {
|
||||
}
|
||||
|
||||
// GetUserSalt returns a ramdom user salt token.
|
||||
func GetUserSalt() string {
|
||||
func GetUserSalt() (string, error) {
|
||||
return base.GetRandomString(10)
|
||||
}
|
||||
|
||||
@@ -604,8 +604,12 @@ func CreateUser(u *User) (err error) {
|
||||
u.LowerName = strings.ToLower(u.Name)
|
||||
u.AvatarEmail = u.Email
|
||||
u.Avatar = base.HashEmail(u.AvatarEmail)
|
||||
u.Rands = GetUserSalt()
|
||||
u.Salt = GetUserSalt()
|
||||
if u.Rands, err = GetUserSalt(); err != nil {
|
||||
return err
|
||||
}
|
||||
if u.Salt, err = GetUserSalt(); err != nil {
|
||||
return err
|
||||
}
|
||||
u.EncodePasswd()
|
||||
u.MaxRepoCreation = -1
|
||||
|
||||
|
Reference in New Issue
Block a user