-
-
Notifications
You must be signed in to change notification settings - Fork 201
/
default.go
29 lines (22 loc) · 869 Bytes
/
default.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package captcha
import (
"html/template"
"github.com/admpub/nging/v4/application/library/common"
"github.com/webx-top/echo"
"github.com/webx-top/echo/middleware/tplfunc"
)
var dflt ICaptcha = &defaultCaptcha{}
type defaultCaptcha struct {
}
func (c *defaultCaptcha) Render(ctx echo.Context, args ...interface{}) template.HTML {
options := tplfunc.MakeMap(args)
options.Set("captchaId", common.GetHistoryOrNewCaptchaID(ctx))
return tplfunc.CaptchaFormWithURLPrefix(ctx.Echo().Prefix(), options)
}
func (c *defaultCaptcha) Verify(ctx echo.Context, hostAlias string, name string, args ...string) echo.Data {
return common.VerifyCaptcha(ctx, hostAlias, name, args...)
}
func (c *defaultCaptcha) MakeData(ctx echo.Context, hostAlias string, name string) echo.H {
cid := common.GetHistoryOrNewCaptchaID(ctx)
return common.CaptchaInfo(hostAlias, name, cid)
}