@@ -0,0 +1,59 @@
|
||||
package certificateser
|
||||
|
||||
import (
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/common/ysqr"
|
||||
"91porn-server/models/v/usermod"
|
||||
"91porn-server/web/middleware/authweb"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// QrCode doc
|
||||
// @Summary 二维码
|
||||
// @Description 二维码
|
||||
// @Tags 凭证
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param token formData string true "令牌"
|
||||
// @Success 200 {string} json "{"msg": "操作成功", "content": "", user:{}}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /ext/certificate/qr [post]
|
||||
func QrCode(c *gin.Context) {
|
||||
var args struct {
|
||||
Token string `form:"token" json:"token" binding:"required"` //token
|
||||
}
|
||||
if err := c.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "certificateser QrCode arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
claims, err := authweb.ParseWebClaims(args.Token)
|
||||
if err != nil {
|
||||
log.Error("activity InvitInfo ParseWebClaims error", log.Any("token", args.Token), log.E(err))
|
||||
common.ServeJSON(c, stderr.InvalidToken, "")
|
||||
return
|
||||
}
|
||||
user, _ := usermod.FindUserByUID(claims.UID)
|
||||
if user == nil {
|
||||
common.ServeJSON(c, stderr.AdminIsNotExist, "")
|
||||
return
|
||||
}
|
||||
content := ysqr.Content{
|
||||
UID: user.UID,
|
||||
T: ysqr.Login,
|
||||
LoginClaims: ysqr.LoginClaims{
|
||||
DevID: user.DevID,
|
||||
},
|
||||
}
|
||||
u := gin.H{
|
||||
"uid": user.UID,
|
||||
"name": user.Name,
|
||||
"portrait": user.Portrait,
|
||||
}
|
||||
common.ServeJSON(c, stderr.Success, gin.H{
|
||||
"content": content.String(authweb.GetTokenSecret()),
|
||||
"user": u,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user