mirror of
https://gitcode.com/flipped-aurora/gin-vue-admin.git
synced 2026-07-21 12:47:50 +00:00
增加验证码接口 修改swagger某些参数错误
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"gin-vue-admin/middleware"
|
||||
"gin-vue-admin/model/modelInterface"
|
||||
"gin-vue-admin/model/sysModel"
|
||||
"github.com/dchest/captcha"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-redis/redis"
|
||||
@@ -23,6 +24,8 @@ var (
|
||||
type RegistAndLoginStuct struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Captcha string `json:"captcha"`
|
||||
CaptchaId string `json:"captchaId"`
|
||||
}
|
||||
|
||||
type RegestStuct struct {
|
||||
@@ -64,12 +67,17 @@ func Regist(c *gin.Context) {
|
||||
func Login(c *gin.Context) {
|
||||
var L RegistAndLoginStuct
|
||||
_ = c.BindJSON(&L)
|
||||
U := &sysModel.SysUser{Username: L.Username, Password: L.Password}
|
||||
if err, user := U.Login(); err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("用户名密码错误或%v", err), gin.H{})
|
||||
} else {
|
||||
tokenNext(c, *user)
|
||||
if captcha.VerifyString(L.CaptchaId,L.Captcha) {
|
||||
U := &sysModel.SysUser{Username: L.Username, Password: L.Password}
|
||||
if err, user := U.Login(); err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("用户名密码错误或%v", err), gin.H{})
|
||||
} else {
|
||||
tokenNext(c, *user)
|
||||
}
|
||||
}else{
|
||||
servers.ReportFormat(c, false, "验证码错误", gin.H{})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//登录以后签发jwt
|
||||
|
||||
Reference in New Issue
Block a user