refactor: project name and set default plan for new user

This commit is contained in:
ericprd
2025-02-27 01:15:47 +08:00
parent 46472d01fe
commit 775a9def75
21 changed files with 123 additions and 66 deletions
+11 -6
View File
@@ -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,