Skip to content

Commit

Permalink
Merge pull request #801 from trheyi/main
Browse files Browse the repository at this point in the history
Translate captcha and password validation error messages to English f…
  • Loading branch information
trheyi authored Dec 2, 2024
2 parents d6f134f + e1af3a8 commit a0885c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions helper/captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,28 @@ func CaptchaMake(option CaptchaOption) (string, string) {

}

// CaptchaValidate 校验验证码
// CaptchaValidate Validate the captcha
func CaptchaValidate(id string, code string) bool {
return captcha.VerifyString(id, code)
}

// ProcessCaptchaValidate xiang.helper.CaptchaValidate 校验图形/音频验证码
// ProcessCaptchaValidate xiang.helper.CaptchaValidate image/audio captcha
func ProcessCaptchaValidate(process *process.Process) interface{} {
process.ValidateArgNums(2)
id := process.ArgsString(0)
code := process.ArgsString(1)
if code == "" {
exception.New("请输入验证码", 400).Throw()
exception.New("Please enter the captcha.", 400).Throw()
return false
}
if !CaptchaValidate(id, code) {
exception.New("验证码不正确", 400).Throw()
exception.New("Invalid captcha.", 400).Throw()
return false
}
return true
}

// ProcessCaptcha xiang.helper.Captcha 校验图形/音频验证码
// ProcessCaptcha xiang.helper.Captcha image/audio captcha
func ProcessCaptcha(process *process.Process) interface{} {
process.ValidateArgNums(1)
option := CaptchaOption{
Expand Down
4 changes: 2 additions & 2 deletions helper/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"golang.org/x/crypto/bcrypt"
)

// PasswordValidate 校验密码
// PasswordValidate Validate the password
func PasswordValidate(password string, passwordHash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(passwordHash), []byte(password))
if err != nil {
exception.New("密码不正确", 400).Throw()
exception.New("Invalid password.", 400).Throw()
return false
}
return true
Expand Down

0 comments on commit a0885c9

Please sign in to comment.