mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-03 15:56:22 +00:00
⚡ update user authentication error handling, add invalid credentials response, and modify .gitignore for data directory
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,4 +7,4 @@
|
||||
.env
|
||||
|
||||
# data
|
||||
./data
|
||||
./data/
|
@ -11,7 +11,7 @@ import (
|
||||
|
||||
type UserService interface {
|
||||
UserLogin(dto *dto.UserLoginReq) (*dto.UserLoginResp, error)
|
||||
UserRegister(dto *dto.UserRegisterReq) (*dto.UserRegisterResp, error)
|
||||
// TODO impl other user-related methods
|
||||
}
|
||||
|
||||
type userService struct{}
|
||||
@ -28,5 +28,9 @@ func (s *userService) UserLogin(dto *dto.UserLoginReq) (*dto.UserLoginResp, erro
|
||||
if user == nil {
|
||||
return nil, errors.New(resps.ErrNotFound)
|
||||
}
|
||||
utils.Password.VerifyPassword(dto.Password, user.Password, utils.Env.Get(constant.EnvVarPasswordSalt, "default_salt"))
|
||||
if utils.Password.VerifyPassword(dto.Password, user.Password, utils.Env.Get(constant.EnvVarPasswordSalt, "default_salt")) {
|
||||
return nil, nil // TODO: Generate JWT token and return it in the response
|
||||
} else {
|
||||
return nil, errors.New(resps.ErrInvalidCredentials)
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,6 @@ const (
|
||||
ErrUnauthorized = "unauthorized access"
|
||||
ErrForbidden = "access forbidden"
|
||||
ErrNotFound = "resource not found"
|
||||
|
||||
ErrInvalidCredentials = "invalid credentials"
|
||||
)
|
||||
|
Reference in New Issue
Block a user