chores: refactor struct and structure project
This commit is contained in:
@@ -4,12 +4,13 @@ import (
|
||||
"errors"
|
||||
|
||||
authdomain "legalgo-BE-go/internal/domain/auth"
|
||||
staffdomain "legalgo-BE-go/internal/domain/staff"
|
||||
"legalgo-BE-go/internal/utilities/utils"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error) {
|
||||
func (a *impl) RegisterStaff(spec staffdomain.StaffRegister) (string, error) {
|
||||
_, err := a.staffRepo.GetStaffByEmail(spec.Email)
|
||||
if err == nil {
|
||||
return "", errors.New("this email address is already in use")
|
||||
@@ -19,7 +20,7 @@ func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
staff := authdomain.Staff{
|
||||
staff := staffdomain.Staff{
|
||||
ID: uuid.NewString(),
|
||||
Email: spec.Email,
|
||||
Password: hashedPwd,
|
||||
@@ -27,7 +28,7 @@ func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error
|
||||
ProfilePicture: spec.ProfilePicture,
|
||||
}
|
||||
|
||||
_, err = a.staffRepo.Create(&staff)
|
||||
err = a.staffRepo.Create(staff)
|
||||
if err != nil {
|
||||
return "", errors.New(err.Error())
|
||||
}
|
||||
@@ -35,6 +36,7 @@ func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error
|
||||
authToken := authdomain.AuthToken{
|
||||
Email: staff.Email,
|
||||
SessionID: uuid.NewString(),
|
||||
Role: "staff",
|
||||
}
|
||||
|
||||
token, err := utils.GenerateToken(authToken)
|
||||
|
||||
Reference in New Issue
Block a user