add DeviceId to userToken
This commit is contained in:
@@ -60,6 +60,7 @@ func (l *Login) Login(c *gin.Context) {
|
|||||||
ut := service.AllService.UserService.Login(u, &model.LoginLog{
|
ut := service.AllService.UserService.Login(u, &model.LoginLog{
|
||||||
UserId: u.Id,
|
UserId: u.Id,
|
||||||
Client: f.DeviceInfo.Type,
|
Client: f.DeviceInfo.Type,
|
||||||
|
DeviceId: f.Id,
|
||||||
Uuid: f.Uuid,
|
Uuid: f.Uuid,
|
||||||
Ip: c.ClientIP(),
|
Ip: c.ClientIP(),
|
||||||
Type: model.LoginLogTypeAccount,
|
Type: model.LoginLogTypeAccount,
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ func (o *Oauth) OidcAuthQueryPre(c *gin.Context) (*model.User, *model.UserToken)
|
|||||||
ut = service.AllService.UserService.Login(u, &model.LoginLog{
|
ut = service.AllService.UserService.Login(u, &model.LoginLog{
|
||||||
UserId: u.Id,
|
UserId: u.Id,
|
||||||
Client: v.DeviceType,
|
Client: v.DeviceType,
|
||||||
|
DeviceId: v.Id,
|
||||||
Uuid: v.Uuid,
|
Uuid: v.Uuid,
|
||||||
Ip: c.ClientIP(),
|
Ip: c.ClientIP(),
|
||||||
Type: model.LoginLogTypeOauth,
|
Type: model.LoginLogTypeOauth,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ type LoginLog struct {
|
|||||||
IdModel
|
IdModel
|
||||||
UserId uint `json:"user_id" gorm:"default:0;not null;"`
|
UserId uint `json:"user_id" gorm:"default:0;not null;"`
|
||||||
Client string `json:"client"` //webadmin,webclient,app,
|
Client string `json:"client"` //webadmin,webclient,app,
|
||||||
|
DeviceId string `json:"device_id"`
|
||||||
Uuid string `json:"uuid"`
|
Uuid string `json:"uuid"`
|
||||||
Ip string `json:"ip"`
|
Ip string `json:"ip"`
|
||||||
Type string `json:"type"` //account,oauth
|
Type string `json:"type"` //account,oauth
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ package model
|
|||||||
type UserToken struct {
|
type UserToken struct {
|
||||||
IdModel
|
IdModel
|
||||||
UserId uint `json:"user_id" gorm:"default:0;not null;index"`
|
UserId uint `json:"user_id" gorm:"default:0;not null;index"`
|
||||||
DeviceUuid string `json:"device_uuid"`
|
DeviceUuid string `json:"device_uuid" gorm:"default:'';omitempty;"`
|
||||||
|
DeviceId string `json:"device_id" gorm:"default:'';omitempty;"`
|
||||||
Token string `json:"token" gorm:"default:'';not null;index"`
|
Token string `json:"token" gorm:"default:'';not null;index"`
|
||||||
ExpiredAt int64 `json:"expired_at" gorm:"default:0;not null;"`
|
ExpiredAt int64 `json:"expired_at" gorm:"default:0;not null;"`
|
||||||
TimeModel
|
TimeModel
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ func (us *UserService) Login(u *model.User, llog *model.LoginLog) *model.UserTok
|
|||||||
UserId: u.Id,
|
UserId: u.Id,
|
||||||
Token: token,
|
Token: token,
|
||||||
DeviceUuid: llog.Uuid,
|
DeviceUuid: llog.Uuid,
|
||||||
|
DeviceId: llog.DeviceId,
|
||||||
ExpiredAt: time.Now().Add(time.Hour * 24 * 7).Unix(),
|
ExpiredAt: time.Now().Add(time.Hour * 24 * 7).Unix(),
|
||||||
}
|
}
|
||||||
global.DB.Create(ut)
|
global.DB.Create(ut)
|
||||||
|
|||||||
Reference in New Issue
Block a user