feat: CR login, register, subscribe
This commit is contained in:
@@ -1,18 +1,24 @@
|
||||
package serviceauth
|
||||
package authsvc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
authdomain "github.com/ardeman/project-legalgo-go/internal/domain/auth"
|
||||
"github.com/ardeman/project-legalgo-go/internal/utilities/utils"
|
||||
)
|
||||
|
||||
func (sv *LoginStaffSvc) LoginAsStaff(email string) (string, error) {
|
||||
staff, err := sv.staffAcs.GetStaff(email)
|
||||
func (sv *AuthSvc) LoginAsStaff(spec authdomain.LoginReq) (string, error) {
|
||||
staff, err := sv.staffRepo.GetStaffByEmail(spec.Email)
|
||||
if err != nil {
|
||||
return "", errors.New(err.Error())
|
||||
}
|
||||
|
||||
token, err := utils.GenerateToken2(staff.Email)
|
||||
matchPassword := ComparePassword(staff.Password, spec.Password)
|
||||
if !matchPassword {
|
||||
return "", errors.New("wrong password")
|
||||
}
|
||||
|
||||
token, err := utils.GenerateToken(staff.Email)
|
||||
if err != nil {
|
||||
return "", errors.New(err.Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user