diff --git a/.gitignore b/.gitignore index 1801170..8faa316 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ .env # data -./data \ No newline at end of file +./data/ \ No newline at end of file diff --git a/internal/service/user.go b/internal/service/user.go index 6993664..727a27d 100644 --- a/internal/service/user.go +++ b/internal/service/user.go @@ -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) + } } diff --git a/pkg/resps/texts.go b/pkg/resps/texts.go index 9db607d..4afde10 100644 --- a/pkg/resps/texts.go +++ b/pkg/resps/texts.go @@ -5,4 +5,6 @@ const ( ErrUnauthorized = "unauthorized access" ErrForbidden = "access forbidden" ErrNotFound = "resource not found" + + ErrInvalidCredentials = "invalid credentials" )