mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
update profile api (#16)
* update profile api * rename * fix realip assertion * add waf api
This commit is contained in:
@@ -2,9 +2,10 @@ package controller
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/naiba/nezha/model"
|
||||
"github.com/naiba/nezha/service/singleton"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
// Get profile
|
||||
@@ -14,14 +15,17 @@ import (
|
||||
// @Description Get profile
|
||||
// @Tags auth required
|
||||
// @Produce json
|
||||
// @Success 200 {object} model.CommonResponse[model.User]
|
||||
// @Success 200 {object} model.CommonResponse[model.Profile]
|
||||
// @Router /profile [get]
|
||||
func getProfile(c *gin.Context) (*model.User, error) {
|
||||
func getProfile(c *gin.Context) (*model.Profile, error) {
|
||||
auth, ok := c.Get(model.CtxKeyAuthorizedUser)
|
||||
if !ok {
|
||||
return nil, singleton.Localizer.ErrorT("unauthorized")
|
||||
}
|
||||
return auth.(*model.User), nil
|
||||
return &model.Profile{
|
||||
User: *auth.(*model.User),
|
||||
LoginIP: c.GetString(model.CtxKeyRealIPStr),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// List user
|
||||
|
||||
Reference in New Issue
Block a user