feat: add short_code field to device login API
- Add optional short_code parameter to DeviceLoginRequest - Add ShortCode field to Device model - Save short_code to database during device registration - Add database migration for user_device.short_code column - Fix duplicate variable declaration in routes.go
This commit is contained in:
parent
ed669d0620
commit
3359704a45
@ -124,6 +124,7 @@ type (
|
||||
IP string `header:"X-Original-Forwarded-For"`
|
||||
UserAgent string `json:"user_agent" validate:"required"`
|
||||
CfToken string `json:"cf_token,optional"`
|
||||
ShortCode string `json:"short_code,optional"`
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
-- Remove short_code column from user_device table
|
||||
ALTER TABLE `user_device` DROP COLUMN `short_code`;
|
||||
@ -0,0 +1,2 @@
|
||||
-- Add short_code column to user_device table
|
||||
ALTER TABLE `user_device` ADD COLUMN `short_code` VARCHAR(255) DEFAULT '' COMMENT 'Short Code' AFTER `identifier`;
|
||||
@ -939,10 +939,10 @@ func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) {
|
||||
serverGroupRouter.GET("/user", server.GetServerUserListHandler(serverCtx))
|
||||
}
|
||||
|
||||
serverV2GroupRouter := router.Group("/v2/server")
|
||||
serverGroupRouterV2 := router.Group("/v2/server")
|
||||
|
||||
{
|
||||
// Get Server Protocol Config
|
||||
serverV2GroupRouter.GET("/:server_id", server.QueryServerProtocolConfigHandler(serverCtx))
|
||||
serverGroupRouterV2.GET("/:server_id", server.QueryServerProtocolConfigHandler(serverCtx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,6 +197,7 @@ func (l *DeviceLoginLogic) registerUserAndDevice(req *types.DeviceLoginRequest)
|
||||
UserId: userInfo.Id,
|
||||
UserAgent: req.UserAgent,
|
||||
Identifier: req.Identifier,
|
||||
ShortCode: req.ShortCode,
|
||||
Enabled: true,
|
||||
Online: false,
|
||||
}
|
||||
|
||||
@ -81,6 +81,7 @@ type Device struct {
|
||||
UserId int64 `gorm:"index:idx_user_id;not null;comment:User ID"`
|
||||
UserAgent string `gorm:"default:null;comment:UserAgent."`
|
||||
Identifier string `gorm:"type:varchar(255);unique;index:idx_identifier;default:'';comment:Device Identifier"`
|
||||
ShortCode string `gorm:"type:varchar(255);default:'';comment:Short Code"`
|
||||
Online bool `gorm:"default:false;not null;comment:Online"`
|
||||
Enabled bool `gorm:"default:true;not null;comment:Enabled"`
|
||||
CreatedAt time.Time `gorm:"<-:create;comment:Creation Time"`
|
||||
|
||||
@ -558,6 +558,7 @@ type DeviceLoginRequest struct {
|
||||
IP string `header:"X-Original-Forwarded-For"`
|
||||
UserAgent string `json:"user_agent" validate:"required"`
|
||||
CfToken string `json:"cf_token,optional"`
|
||||
ShortCode string `json:"short_code,optional"`
|
||||
}
|
||||
|
||||
type Document struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user