feat: CR login, register, subscribe
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package authsvc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
authdomain "github.com/ardeman/project-legalgo-go/internal/domain/auth"
|
||||
"github.com/ardeman/project-legalgo-go/internal/utilities/utils"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (a *AuthSvc) RegisterStaff(spec authdomain.RegisterStaffReq) (string, error) {
|
||||
hashedPwd, err := HashPassword(spec.Password)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
user := authdomain.Staff{
|
||||
ID: uuid.New(),
|
||||
Email: spec.Email,
|
||||
Password: hashedPwd,
|
||||
}
|
||||
|
||||
_, err = a.staffRepo.Create(&user)
|
||||
if err != nil {
|
||||
return "", errors.New(err.Error())
|
||||
}
|
||||
|
||||
token, err := utils.GenerateToken(spec.Email)
|
||||
if err != nil {
|
||||
return "", errors.New(err.Error())
|
||||
}
|
||||
return token, nil
|
||||
}
|
||||
Reference in New Issue
Block a user