用户登录 + 验证码 + 用户输出
This commit is contained in:
parent
6f603541b6
commit
ce627aedb7
3 changed files with 30 additions and 4 deletions
|
|
@ -136,6 +136,11 @@ func (cfg *Config) SetDefaults() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsDebug 是否为调试模式
|
||||||
|
func IsDebug() bool {
|
||||||
|
return Conf.Mode == "debug"
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Conf = NewConfig()
|
Conf = NewConfig()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,8 @@ func MakeCaptcha(option CaptchaOption) (string, string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打印日志
|
// 打印日志
|
||||||
if config.Conf.Mode == "debug" {
|
if config.IsDebug() {
|
||||||
xlog.Println("图形/音频验证码:", captchaStore.Get(id, false))
|
xlog.Println("图形/音频 ID:", id, "验证码:", captchaStore.Get(id, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
return id, content
|
return id, content
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"github.com/yaoapp/kun/exception"
|
"github.com/yaoapp/kun/exception"
|
||||||
"github.com/yaoapp/kun/maps"
|
"github.com/yaoapp/kun/maps"
|
||||||
"github.com/yaoapp/kun/utils"
|
"github.com/yaoapp/kun/utils"
|
||||||
|
"github.com/yaoapp/xiang/config"
|
||||||
|
"github.com/yaoapp/xiang/xlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -16,8 +18,27 @@ func init() {
|
||||||
// ProcessLogin xiang.user.Login 用户登录
|
// ProcessLogin xiang.user.Login 用户登录
|
||||||
func ProcessLogin(process *gou.Process) interface{} {
|
func ProcessLogin(process *gou.Process) interface{} {
|
||||||
process.ValidateArgNums(1)
|
process.ValidateArgNums(1)
|
||||||
payload := process.ArgsMap(0)
|
payload := process.ArgsMap(0).Dot()
|
||||||
utils.Dump(payload)
|
if config.IsDebug() {
|
||||||
|
xlog.Println(payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
id := any.Of(payload.Get("captcha.id")).CString()
|
||||||
|
value := any.Of(payload.Get("captcha.code")).CString()
|
||||||
|
if id == "" {
|
||||||
|
exception.New("请输入验证码ID", 400).Ctx(maps.Map{"id": id, "code": value}).Throw()
|
||||||
|
}
|
||||||
|
if value == "" {
|
||||||
|
exception.New("请输入验证码", 400).Ctx(maps.Map{"id": id, "code": value}).Throw()
|
||||||
|
}
|
||||||
|
if !ValidateCaptcha(id, value) {
|
||||||
|
if config.IsDebug() {
|
||||||
|
xlog.Println("ID:", id, " Code:", value)
|
||||||
|
}
|
||||||
|
exception.New("验证码不正确", 403).Ctx(maps.Map{"id": id, "code": value}).Throw()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
email := any.Of(payload.Get("email")).CString()
|
email := any.Of(payload.Get("email")).CString()
|
||||||
mobile := any.Of(payload.Get("mobile")).CString()
|
mobile := any.Of(payload.Get("mobile")).CString()
|
||||||
password := any.Of(payload.Get("password")).CString()
|
password := any.Of(payload.Get("password")).CString()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue