Skip to content

Commit

Permalink
feat: remove apikey register
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Aug 5, 2023
1 parent c9fec9a commit c4cb0d0
Showing 1 changed file with 37 additions and 39 deletions.
76 changes: 37 additions & 39 deletions apis/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,45 +529,43 @@ func verifyWithEmail(c *fiber.Ctx, email, givenScope string, check bool) error {
// @Failure 403 {object} common.MessageResponse "apikey不正确"
// @Failure 409 {object} common.MessageResponse "用户已注册"
// @Failure 500 {object} common.MessageResponse
func VerifyWithApikey(c *fiber.Ctx) error {
if config.RegisterApikeySecret == "" {
return common.Forbidden("API Key 注册已禁用")
}

var query ApikeyRequest
err := common.ValidateQuery(c, &query)
if err != nil {
return err
}

scope := "register"
if !auth.CheckApikey(query.Apikey) {
return common.Forbidden("API Key 不正确,您可以选择使用旦夕账号登录,或者在 auth.fduhole.com 注册旦夕账户")
}
ok, err := HasRegisteredEmail(DB, query.Email)
if err != nil {
return err
}

if ok {
return c.Status(409).JSON(common.HttpError{Code: 409, Message: "用户已注册"})
}
if query.CheckRegister {
return c.Status(200).JSON(common.HttpError{Code: 200, Message: "用户已注册"})
}

code, err := auth.SetVerificationCode(query.Email, scope)
if err != nil {
return err
}

return c.JSON(ApikeyResponse{
EmailVerifyResponse: EmailVerifyResponse{
Message: "验证成功",
Scope: scope,
},
Code: code,
})
func VerifyWithApikey(_ *fiber.Ctx) error {
return common.Forbidden("API Key 注册已禁用")

//var query ApikeyRequest
//err := common.ValidateQuery(c, &query)
//if err != nil {
// return err
//}
//
//scope := "register"
//if !auth.CheckApikey(query.Apikey) {
// return common.Forbidden("API Key 不正确,您可以选择使用旦夕账号登录,或者在 auth.fduhole.com 注册旦夕账户")
//}
//ok, err := HasRegisteredEmail(DB, query.Email)
//if err != nil {
// return err
//}
//
//if ok {
// return c.Status(409).JSON(common.HttpError{Code: 409, Message: "用户已注册"})
//}
//if query.CheckRegister {
// return c.Status(200).JSON(common.HttpError{Code: 200, Message: "用户已注册"})
//}
//
//code, err := auth.SetVerificationCode(query.Email, scope)
//if err != nil {
// return err
//}
//
//return c.JSON(ApikeyResponse{
// EmailVerifyResponse: EmailVerifyResponse{
// Message: "验证成功",
// Scope: scope,
// },
// Code: code,
//})
}

// DeleteUser godoc
Expand Down

0 comments on commit c4cb0d0

Please sign in to comment.