mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: captcha
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"cloudreve/pkg/util"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mojocn/base64Captcha"
|
||||
)
|
||||
|
||||
// UserLoginService 管理用户登录的服务
|
||||
@@ -23,6 +24,11 @@ func (service *UserLoginService) Login(c *gin.Context) serializer.Response {
|
||||
|
||||
if model.IsTrueVal(isCaptchaRequired) {
|
||||
// TODO 验证码校验
|
||||
captchaID := util.GetSession(c, "captchaID")
|
||||
if captchaID == nil || !base64Captcha.VerifyCaptcha(captchaID.(string), service.CaptchaCode) {
|
||||
util.DeleteSession(c, "captchaID")
|
||||
return serializer.ParamErr("验证码错误", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// 一系列校验
|
||||
|
||||
Reference in New Issue
Block a user