mirror of
https://github.com/gotify/server.git
synced 2026-05-06 21:42:07 +08:00
fix: return client id and elevatedUntil on /current/user
This commit is contained in:
@@ -43,7 +43,7 @@ type SessionAPI struct {
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/UserExternal"
|
||||
// $ref: "#/definitions/CurrentUser"
|
||||
// headers:
|
||||
// Set-Cookie:
|
||||
// type: string
|
||||
@@ -85,10 +85,12 @@ func (a *SessionAPI) Login(ctx *gin.Context) {
|
||||
|
||||
auth.SetCookie(ctx.Writer, client.Token, auth.CookieMaxAge, a.SecureCookie)
|
||||
|
||||
ctx.JSON(200, &model.UserExternal{
|
||||
ID: user.ID,
|
||||
Name: user.Name,
|
||||
Admin: user.Admin,
|
||||
ctx.JSON(200, &model.CurrentUserExternal{
|
||||
ID: user.ID,
|
||||
Name: user.Name,
|
||||
Admin: user.Admin,
|
||||
ClientID: client.ID,
|
||||
ElevatedUntil: client.ElevatedUntil,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
12
api/user.go
12
api/user.go
@@ -126,7 +126,17 @@ func (a *UserAPI) GetCurrentUser(ctx *gin.Context) {
|
||||
if success := successOrAbort(ctx, 500, err); !success {
|
||||
return
|
||||
}
|
||||
ctx.JSON(200, toExternalUser(user))
|
||||
result := &model.CurrentUserExternal{
|
||||
ID: user.ID,
|
||||
Name: user.Name,
|
||||
Admin: user.Admin,
|
||||
}
|
||||
client := auth.GetClient(ctx)
|
||||
if client != nil {
|
||||
result.ClientID = client.ID
|
||||
result.ElevatedUntil = client.ElevatedUntil
|
||||
}
|
||||
ctx.JSON(200, result)
|
||||
}
|
||||
|
||||
// CreateUser create a user.
|
||||
|
||||
Reference in New Issue
Block a user