diff --git a/apis/auth/auth.api b/apis/auth/auth.api index 8211bef..6e6d03c 100644 --- a/apis/auth/auth.api +++ b/apis/auth/auth.api @@ -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"` } ) diff --git a/initialize/migrate/database/02129_device_short_code.down.sql b/initialize/migrate/database/02129_device_short_code.down.sql new file mode 100644 index 0000000..c134d7f --- /dev/null +++ b/initialize/migrate/database/02129_device_short_code.down.sql @@ -0,0 +1,2 @@ +-- Remove short_code column from user_device table +ALTER TABLE `user_device` DROP COLUMN `short_code`; diff --git a/initialize/migrate/database/02129_device_short_code.up.sql b/initialize/migrate/database/02129_device_short_code.up.sql new file mode 100644 index 0000000..64245b8 --- /dev/null +++ b/initialize/migrate/database/02129_device_short_code.up.sql @@ -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`; diff --git a/internal/handler/routes.go b/internal/handler/routes.go index ff26e9f..d95465a 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -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)) } } diff --git a/internal/logic/auth/deviceLoginLogic.go b/internal/logic/auth/deviceLoginLogic.go index 985813e..8c0926d 100644 --- a/internal/logic/auth/deviceLoginLogic.go +++ b/internal/logic/auth/deviceLoginLogic.go @@ -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, } diff --git a/internal/model/user/user.go b/internal/model/user/user.go index 30fa804..9077c87 100644 --- a/internal/model/user/user.go +++ b/internal/model/user/user.go @@ -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"` diff --git a/internal/types/types.go b/internal/types/types.go index 5369547..7fe6027 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -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 {