add initial space logic/behaviour
This commit is contained in:
parent
07ebc06b32
commit
219d254b96
10 changed files with 333 additions and 0 deletions
|
|
@ -36,6 +36,7 @@ type AuthService struct {
|
|||
userRepository repository.UserRepository
|
||||
profileRepository repository.ProfileRepository
|
||||
tokenRepository repository.TokenRepository
|
||||
spaceService *SpaceService
|
||||
jwtSecret string
|
||||
jwtExpiry time.Duration
|
||||
tokenMagicLinkExpiry time.Duration
|
||||
|
|
@ -47,6 +48,7 @@ func NewAuthService(
|
|||
userRepository repository.UserRepository,
|
||||
profileRepository repository.ProfileRepository,
|
||||
tokenRepository repository.TokenRepository,
|
||||
spaceService *SpaceService,
|
||||
jwtSecret string,
|
||||
jwtExpiry time.Duration,
|
||||
tokenMagicLinkExpiry time.Duration,
|
||||
|
|
@ -57,6 +59,7 @@ func NewAuthService(
|
|||
userRepository: userRepository,
|
||||
profileRepository: profileRepository,
|
||||
tokenRepository: tokenRepository,
|
||||
spaceService: spaceService,
|
||||
jwtSecret: jwtSecret,
|
||||
jwtExpiry: jwtExpiry,
|
||||
tokenMagicLinkExpiry: tokenMagicLinkExpiry,
|
||||
|
|
@ -214,6 +217,12 @@ func (s *AuthService) SendMagicLink(email string) error {
|
|||
return fmt.Errorf("failed to create profile: %w", err)
|
||||
}
|
||||
|
||||
_, err = s.spaceService.EnsurePersonalSpace(user)
|
||||
if err != nil {
|
||||
// Log the error but don't fail the whole auth flow
|
||||
slog.Error("failed to create personal space for new user", "error", err, "user_id", user.ID)
|
||||
}
|
||||
|
||||
slog.Info("new passwordless user created", "email", email, "user_id", user.ID)
|
||||
} else {
|
||||
// user look up unexpected error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue