Skip to content

Commit

Permalink
feat: remove ErrLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Aug 12, 2023
1 parent 30dab78 commit ba462d0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions apis/token.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package apis

import (
"github.com/gofiber/fiber/v2"
"github.com/opentreehole/go-common"

"auth_next/config"
. "auth_next/models"
"auth_next/utils/auth"
"auth_next/utils/kong"
"github.com/gofiber/fiber/v2"
"github.com/opentreehole/go-common"
)

var ErrLogin = common.Forbidden("邮箱或密码错误")

// Login godoc
//
// @Summary Login
Expand All @@ -36,15 +35,15 @@ func Login(c *fiber.Ctx) error {
Where("identifier = ? AND is_active = true", auth.MakeIdentifier(body.Email)).
Take(&user).Error
if err != nil {
return ErrLogin
return common.Forbidden("账号未注册")
}

ok, err := auth.CheckPassword(body.Password, user.Password)
if err != nil {
return err
}
if !ok {
return ErrLogin
return common.Unauthorized("密码错误")
}

if config.Config.ShamirFeature {
Expand Down

0 comments on commit ba462d0

Please sign in to comment.