mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-29 07:03:55 +03:00
Add LastLogin to the User API (#7196)
This commit is contained in:
parent
273f1997ff
commit
cf2221e3ac
4 changed files with 19 additions and 0 deletions
|
@ -214,6 +214,8 @@ func (u *User) APIFormat() *api.User {
|
||||||
AvatarURL: u.AvatarLink(),
|
AvatarURL: u.AvatarLink(),
|
||||||
Language: u.Language,
|
Language: u.Language,
|
||||||
IsAdmin: u.IsAdmin,
|
IsAdmin: u.IsAdmin,
|
||||||
|
LastLogin: u.LastLoginUnix.AsTime(),
|
||||||
|
Created: u.CreatedUnix.AsTime(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ package structs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User represents a user
|
// User represents a user
|
||||||
|
@ -25,6 +26,10 @@ type User struct {
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
// Is the user an administrator
|
// Is the user an administrator
|
||||||
IsAdmin bool `json:"is_admin"`
|
IsAdmin bool `json:"is_admin"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
|
LastLogin time.Time `json:"last_login,omitempty"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
|
Created time.Time `json:"created,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
||||||
|
|
|
@ -236,6 +236,8 @@ func ToUser(user *models.User, signed, admin bool) *api.User {
|
||||||
AvatarURL: user.AvatarLink(),
|
AvatarURL: user.AvatarLink(),
|
||||||
FullName: markup.Sanitize(user.FullName),
|
FullName: markup.Sanitize(user.FullName),
|
||||||
IsAdmin: user.IsAdmin,
|
IsAdmin: user.IsAdmin,
|
||||||
|
LastLogin: user.LastLoginUnix.AsTime(),
|
||||||
|
Created: user.CreatedUnix.AsTime(),
|
||||||
}
|
}
|
||||||
if signed && (!user.KeepEmailPrivate || admin) {
|
if signed && (!user.KeepEmailPrivate || admin) {
|
||||||
result.Email = user.Email
|
result.Email = user.Email
|
||||||
|
|
|
@ -9715,6 +9715,11 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "AvatarURL"
|
"x-go-name": "AvatarURL"
|
||||||
},
|
},
|
||||||
|
"created": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"x-go-name": "Created"
|
||||||
|
},
|
||||||
"email": {
|
"email": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "email",
|
"format": "email",
|
||||||
|
@ -9741,6 +9746,11 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Language"
|
"x-go-name": "Language"
|
||||||
},
|
},
|
||||||
|
"last_login": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"x-go-name": "LastLogin"
|
||||||
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"description": "the user's username",
|
"description": "the user's username",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
Loading…
Reference in a new issue