Add github.com/dchest/captcha imports.

This commit is contained in:
Yang Luo
2021-05-08 23:24:30 +08:00
parent de67ee9014
commit a1851c2b78
5 changed files with 50 additions and 29 deletions

26
object/captcha.go Normal file
View File

@ -0,0 +1,26 @@
package object
import (
"bytes"
"github.com/dchest/captcha"
)
func GetCaptcha() (string, []byte) {
id := captcha.NewLen(5)
var buffer bytes.Buffer
err := captcha.WriteImage(&buffer, id, 200, 80)
if err != nil {
panic(err)
}
return id, buffer.Bytes()
}
func VerifyCaptcha(id string, digits string) bool {
res := captcha.VerifyString(id, digits)
return res
}

View File

@ -92,7 +92,3 @@ func CheckUserLogin(organization string, username string, password string) (*Use
return user, ""
}
func (user *User) GetId() string {
return fmt.Sprintf("%s/%s", user.Owner, user.Name)
}