1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-16 07:04:25 +00:00

Merge pull request #1211 from mephux/hotfix/type-fix-ValidatePassword

Hotfix/type fix validate password
This commit is contained in:
Lunny Xiao 2015-04-24 15:03:21 +08:00
commit 673a76d638
4 changed files with 5 additions and 5 deletions

View File

@ -169,7 +169,7 @@ func UserSignIn(uname, passwd string) (*User, error) {
// For plain login, user must exist to reach this line. // For plain login, user must exist to reach this line.
// Now verify password. // Now verify password.
if u.LoginType == PLAIN { if u.LoginType == PLAIN {
if !u.ValidtePassword(passwd) { if !u.ValidatePassword(passwd) {
return nil, ErrUserNotExist return nil, ErrUserNotExist
} }
return u, nil return u, nil

View File

@ -143,8 +143,8 @@ func (u *User) EncodePasswd() {
u.Passwd = fmt.Sprintf("%x", newPasswd) u.Passwd = fmt.Sprintf("%x", newPasswd)
} }
// ValidtePassword checks if given password matches the one belongs to the user. // ValidatePassword checks if given password matches the one belongs to the user.
func (u *User) ValidtePassword(passwd string) bool { func (u *User) ValidatePassword(passwd string) bool {
newUser := &User{Passwd: passwd, Salt: u.Salt} newUser := &User{Passwd: passwd, Salt: u.Salt}
newUser.EncodePasswd() newUser.EncodePasswd()
return u.Passwd == newUser.Passwd return u.Passwd == newUser.Passwd

View File

@ -164,7 +164,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {
} }
return return
} }
if !u.ValidtePassword(ctx.Query("password")) { if !u.ValidatePassword(ctx.Query("password")) {
ctx.HandleAPI(422, "Username or password is not correct.") ctx.HandleAPI(422, "Username or password is not correct.")
return return
} }