We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gfToken.GetTokenData(r).Data
it can't get Data, show ERROR:
2024-08-18 19:53:50.279 [ERRO] {cc5af3c185d0ec17ef56120c30a510df} [GToken]token decode error NL4h2VWnkTTSPtPYrPMiuSbRzgdUobEZ tMJO1zHqXGu6boS s4T p/43Ob4WMaA base64.StdEncoding.Decode failed: illegal base64 data at input byte 32 Stack:
// 登录前置 func LoginBefore(r *ghttp.Request) (string, interface{}) { username := r.Get("username").String() passwd := r.Get("password").String() password, err := utility.HashPassword(passwd, username) if err != nil { r.Response.WriteJsonExit(g.Map{ "state": consts.ERROR, "message": "密码加密失败!", }) } ctx := r.Context() var employee = new(entity.Employee) er := dao.Employee.Ctx(ctx).Where(g.Map{ dao.Employee.Columns().LoginName: username, dao.Employee.Columns().PasswordHash: password, }).Scan(&employee) if er != nil { r.Response.WriteJsonExit(g.Map{ "state": consts.ERROR, "message": "数据库查询错误", }) } else if employee == nil { r.Response.WriteJsonExit(g.Map{ "state": consts.ERROR, "message": "用户名或密码错误!", }) } var accountType = new(entity.AccountType) er = dao.AccountType.Ctx(ctx).WherePri(employee.TypeId).Scan(&accountType) if er != nil { r.Response.WriteJsonExit(g.Map{ "state": consts.ERROR, "message": "数据库查询错误", }) } else if accountType == nil { r.Response.WriteJsonExit(g.Map{ "state": consts.ERROR, "message": "查询账户类型表数据错误!", }) } return username, "22222" }
// 登录成功后返回token func LoginAfter(r *ghttp.Request, respData gtoken.Resp) { token := respData.GetString(gtoken.KeyToken) fmt.Println("token:", token) fmt.Println("resp:", respData.Data)
fmt.Println("data:", respData.Get("data"),"<---") var p model.TokenInfo err := gconv.Struct(respData.GetString("data"), &p) if err != nil { // 如果类型转换失败,返回错误 r.Response.WriteJsonExit(g.Map{ "state": consts.ERROR, "message": "解析Token数据失败", }) } fmt.Println("employee:", p.Employee) fmt.Println("accountType:", p.AccountType) if respData.Success() { r.Response.WriteJsonExit(g.Map{ "state": consts.SUCCESS, "message": "登录成功!", "data": g.Map{ "token": token, "employee": p.Employee, "accountType": p.AccountType, }, }) } else { r.Response.WriteJsonExit(g.Map{ "state": consts.ERROR, "message": "登录失败!", }) }
}
token: V4bR14kOR7oYu2chbIx7u9JWZW+vXrNQEusXqpIjVhMthexcolBbQso4KxId8N0O resp: map[token:V4bR14kOR7oYu2chbIx7u9JWZW+vXrNQEusXqpIjVhMthexcolBbQso4KxId8N0O userKey:admin uuid:efb9eb0464f20ddeac1acb7a73dd3dad] data: <---
I can't get "22222"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
gfToken.GetTokenData(r).Data
it can't get Data, show ERROR:
2024-08-18 19:53:50.279 [ERRO] {cc5af3c185d0ec17ef56120c30a510df} [GToken]token decode error NL4h2VWnkTTSPtPYrPMiuSbRzgdUobEZ tMJO1zHqXGu6boS s4T p/43Ob4WMaA base64.StdEncoding.Decode failed: illegal base64 data at input byte 32
Stack:
E:/test/gtoken-master/gtoken/gtoken.go:352
E:/test/gtoken-master/gtoken/gtoken.go:258
E:/test/gtoken-master/gtoken/gtoken.go:127
// 登录前置
func LoginBefore(r *ghttp.Request) (string, interface{}) {
username := r.Get("username").String()
passwd := r.Get("password").String()
password, err := utility.HashPassword(passwd, username)
if err != nil {
r.Response.WriteJsonExit(g.Map{
"state": consts.ERROR,
"message": "密码加密失败!",
})
}
ctx := r.Context()
var employee = new(entity.Employee)
er := dao.Employee.Ctx(ctx).Where(g.Map{
dao.Employee.Columns().LoginName: username,
dao.Employee.Columns().PasswordHash: password,
}).Scan(&employee)
if er != nil {
r.Response.WriteJsonExit(g.Map{
"state": consts.ERROR,
"message": "数据库查询错误",
})
} else if employee == nil {
r.Response.WriteJsonExit(g.Map{
"state": consts.ERROR,
"message": "用户名或密码错误!",
})
}
var accountType = new(entity.AccountType)
er = dao.AccountType.Ctx(ctx).WherePri(employee.TypeId).Scan(&accountType)
if er != nil {
r.Response.WriteJsonExit(g.Map{
"state": consts.ERROR,
"message": "数据库查询错误",
})
} else if accountType == nil {
r.Response.WriteJsonExit(g.Map{
"state": consts.ERROR,
"message": "查询账户类型表数据错误!",
})
}
return username, "22222"
}
// 登录成功后返回token
func LoginAfter(r *ghttp.Request, respData gtoken.Resp) {
token := respData.GetString(gtoken.KeyToken)
fmt.Println("token:", token)
fmt.Println("resp:", respData.Data)
}
token: V4bR14kOR7oYu2chbIx7u9JWZW+vXrNQEusXqpIjVhMthexcolBbQso4KxId8N0O
resp: map[token:V4bR14kOR7oYu2chbIx7u9JWZW+vXrNQEusXqpIjVhMthexcolBbQso4KxId8N0O userKey:admin uuid:efb9eb0464f20ddeac1acb7a73dd3dad]
data: <---
I can't get "22222"
The text was updated successfully, but these errors were encountered: