修改了登录接口
This commit is contained in:
parent
ec7df630f8
commit
dc84dbbb44
@ -245,7 +245,7 @@ func (b *Public) LoginProgram(c *gin.Context) {
|
||||
req := publicRequest.LoginProgram
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "登录失败",
|
||||
"message": "登录失败1",
|
||||
"code": -2,
|
||||
"data": gin.H{
|
||||
"source": 2,
|
||||
@ -258,7 +258,7 @@ func (b *Public) LoginProgram(c *gin.Context) {
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "登录失败",
|
||||
"message": "登录失败2",
|
||||
"code": -2,
|
||||
"data": gin.H{
|
||||
"source": 2,
|
||||
@ -272,7 +272,7 @@ func (b *Public) LoginProgram(c *gin.Context) {
|
||||
t, err := utils.ParseJwt(req.Token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "登录失败",
|
||||
"message": "登录失败3",
|
||||
"code": -2,
|
||||
"data": gin.H{
|
||||
"source": 2,
|
||||
@ -286,7 +286,7 @@ func (b *Public) LoginProgram(c *gin.Context) {
|
||||
userId, err := strconv.ParseInt(t.UserId, 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "登录失败",
|
||||
"message": "登录失败4",
|
||||
"code": -2,
|
||||
"data": gin.H{
|
||||
"source": 2,
|
||||
@ -313,17 +313,36 @@ func (b *Public) LoginProgram(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var platformId int
|
||||
if user.RegisterSource == 2 {
|
||||
platformId = 1
|
||||
} else if user.RegisterSource == 3 {
|
||||
platformId = 2
|
||||
}
|
||||
|
||||
if platformId == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "登录失败",
|
||||
"code": -2,
|
||||
"data": gin.H{
|
||||
"source": 2,
|
||||
},
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 下发token
|
||||
token := &utils.Token{
|
||||
UserId: fmt.Sprintf("%d", user.UserId),
|
||||
PlatformId: fmt.Sprintf("%d", 2),
|
||||
PlatformId: fmt.Sprintf("%d", platformId),
|
||||
}
|
||||
|
||||
// 生成jwt
|
||||
jwt, err := token.NewJWT()
|
||||
if err != nil || jwt == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "登陆失败",
|
||||
"message": "登陆失败6",
|
||||
"code": -1,
|
||||
"data": gin.H{
|
||||
"source": 2,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user