You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
690 B
Go
32 lines
690 B
Go
package captcha
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
|
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
|
|
|
"net/http"
|
|
)
|
|
|
|
type ValidateCaptchaLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
r *http.Request
|
|
}
|
|
|
|
func NewValidateCaptchaLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *ValidateCaptchaLogic {
|
|
return &ValidateCaptchaLogic{
|
|
r: r,
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *ValidateCaptchaLogic) ValidateCaptcha(req *types.ValidateCaptchaReq) error {
|
|
if err := l.svcCtx.Captcha.Verify(req.CaptchaId, req.Captcha, req.Clear); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|