feat: add get-user-by-token api
This commit is contained in:
parent
0d19ec267f
commit
6d24b07573
|
@ -209,6 +209,7 @@ func configRoutes(r *gin.Engine) {
|
|||
v1.GET("/can-do-op-by-name", login(), canDoOpByName)
|
||||
v1.GET("/can-do-op-by-token", login(), canDoOpByToken)
|
||||
v1.GET("/get-user-by-name", login(), getUserByName)
|
||||
v1.GET("/get-user-by-token", login(), getUserByToken)
|
||||
}
|
||||
|
||||
push := r.Group("/v1/n9e/series").Use(gzip.Gzip(gzip.DefaultCompression))
|
||||
|
|
|
@ -90,8 +90,3 @@ func canDoOpByToken(c *gin.Context) {
|
|||
can, err := user.CanDo(queryStr(c, "op"))
|
||||
renderData(c, can, err)
|
||||
}
|
||||
|
||||
func getUserByName(c *gin.Context) {
|
||||
user, err := models.UserGetByUsername(queryStr(c, "name"))
|
||||
renderData(c, user, err)
|
||||
}
|
||||
|
|
|
@ -178,3 +178,20 @@ func userDel(c *gin.Context) {
|
|||
func contactChannelsGet(c *gin.Context) {
|
||||
renderData(c, config.Config.ContactKeys, nil)
|
||||
}
|
||||
|
||||
func getUserByName(c *gin.Context) {
|
||||
user, err := models.UserGetByUsername(queryStr(c, "name"))
|
||||
renderData(c, user, err)
|
||||
}
|
||||
|
||||
func getUserByToken(c *gin.Context) {
|
||||
userToken, err := models.UserTokenGet("token=?", queryStr(c, "token"))
|
||||
dangerous(err)
|
||||
if userToken == nil {
|
||||
renderMessage(c, nil)
|
||||
return
|
||||
}
|
||||
|
||||
user, err := models.UserGetByUsername(userToken.Username)
|
||||
renderData(c, user, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue