Skip to content

Commit 05e47b6

Browse files
committed
feat: only admin can RegisterDebug
1 parent 5fcc64d commit 05e47b6

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

apis/account.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ func Register(c *fiber.Ctx) (err error) {
6969
// @Failure 500 {object} common.MessageResponse
7070
// @Security ApiKeyAuth
7171
func RegisterDebug(c *fiber.Ctx) (err error) {
72+
operatorID, err := common.GetUserID(c)
73+
if err != nil {
74+
return err
75+
}
76+
if !IsAdmin(operatorID) {
77+
return common.Forbidden()
78+
}
79+
7280
var body LoginRequest
7381
err = common.ValidateBody(c, &body)
7482
if err != nil {
@@ -92,6 +100,14 @@ func RegisterDebug(c *fiber.Ctx) (err error) {
92100
// @Failure 500 {object} common.MessageResponse
93101
// @Security ApiKeyAuth
94102
func RegisterDebugInBatch(c *fiber.Ctx) (err error) {
103+
operatorID, err := common.GetUserID(c)
104+
if err != nil {
105+
return err
106+
}
107+
if !IsAdmin(operatorID) {
108+
return common.Forbidden()
109+
}
110+
95111
const taskScope = "register_in_batch"
96112
log.Info().Str("scope", taskScope).Msg("register in batch")
97113

0 commit comments

Comments
 (0)