refactor: project name and set default plan for new user
This commit is contained in:
@@ -15,13 +15,18 @@ func (a *AuthSvc) RegisterUser(spec authdomain.RegisterUserReq) (string, error)
|
||||
return "", errors.New("this email address is already in use")
|
||||
}
|
||||
|
||||
var subsId string
|
||||
|
||||
if spec.SubscribePlanID != "" {
|
||||
subsId, err = a.subsRepo.Create(spec.SubscribePlanID)
|
||||
if spec.SubscribePlanID == "" {
|
||||
subsPlan, err := a.subsPlanRepo.GetDefault()
|
||||
if err != nil {
|
||||
return "", nil
|
||||
return "", err
|
||||
}
|
||||
|
||||
spec.SubscribePlanID = subsPlan.ID
|
||||
}
|
||||
|
||||
subsId, err := a.subsRepo.Create(spec.SubscribePlanID)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
hashedPwd, err := HashPassword(spec.Password)
|
||||
@@ -30,7 +35,7 @@ func (a *AuthSvc) RegisterUser(spec authdomain.RegisterUserReq) (string, error)
|
||||
}
|
||||
|
||||
user := authdomain.User{
|
||||
ID: uuid.New(),
|
||||
ID: uuid.NewString(),
|
||||
Email: spec.Email,
|
||||
SubscribeID: subsId,
|
||||
Password: hashedPwd,
|
||||
|
||||
Reference in New Issue
Block a user