update config

This commit is contained in:
aditya.siregar
2025-05-03 10:50:41 +07:00
parent d77f7c7981
commit f0a7c6352f
18 changed files with 438 additions and 55 deletions
+7
View File
@@ -15,10 +15,15 @@ type RegistrationService interface {
ResendOTP(ctx mycontext.Context, token string) (*entity.ResendOTPResponse, error)
}
type CryptoSvc interface {
GenerateJWTCustomer(user *entity.Customer) (string, error)
}
type memberSvc struct {
repo Repository
notification NotificationService
customerSvc CustomerService
crypt CryptoSvc
}
type Repository interface {
@@ -42,10 +47,12 @@ func NewMemberRegistrationService(
repo Repository,
notification NotificationService,
customerSvc CustomerService,
crypt CryptoSvc,
) RegistrationService {
return &memberSvc{
repo: repo,
notification: notification,
customerSvc: customerSvc,
crypt: crypt,
}
}
+25 -17
View File
@@ -38,11 +38,12 @@ func (s *memberSvc) InitiateRegistration(
BirthDate: request.BirthDate,
OTP: otp,
Status: constants.RegistrationPending,
ExpiresAt: constants.TimeNow().Add(10 * time.Minute), // OTP expires in 10 minutes
ExpiresAt: constants.TimeNow().Add(10 * time.Minute),
CreatedAt: constants.TimeNow(),
UpdatedAt: constants.TimeNow(),
BranchID: request.BranchID,
CashierID: request.CashierID,
Password: request.GetHashPassword(),
}
savedRegistration, err := s.repo.CreateRegistration(ctx, registration)
@@ -125,7 +126,14 @@ func (s *memberSvc) VerifyOTP(
logger.ContextLogger(ctx).Warn("failed to send welcome email", zap.Error(err))
}
signedToken, err := s.crypt.GenerateJWTCustomer(customer)
if err != nil {
return nil, err
}
return &entity.MemberVerificationResponse{
Auth: customer.ToUserAuthenticate(signedToken),
CustomerID: customer.ID,
Name: customer.Name,
Email: customer.Email,
@@ -200,23 +208,23 @@ func (s *memberSvc) sendRegistrationOTP(
ctx mycontext.Context,
registration *entity.MemberRegistration,
) error {
emailData := map[string]interface{}{
"UserName": registration.Name,
"OTPCode": registration.OTP,
}
//emailData := map[string]interface{}{
// "UserName": registration.Name,
// "OTPCode": registration.OTP,
//}
err := s.notification.SendEmailTransactional(ctx, entity.SendEmailNotificationParam{
Sender: "noreply@enaklo.co.id",
Recipient: registration.Email,
Subject: "Enaklo - Registration Verification Code",
TemplateName: "member_registration_otp",
TemplatePath: "templates/member_registration_otp.html",
Data: emailData,
})
if err != nil {
return err
}
//err := s.notification.SendEmailTransactional(ctx, entity.SendEmailNotificationParam{
// Sender: "noreply@enaklo.co.id",
// Recipient: registration.Email,
// Subject: "Enaklo - Registration Verification Code",
// TemplateName: "member_registration_otp",
// TemplatePath: "templates/member_registration_otp.html",
// Data: emailData,
//})
//
//if err != nil {
// return err
//}
//if registration.Phone != "" {
// smsMessage := fmt.Sprintf("Your Enaklo registration code is: %s. Please provide this code to our staff to complete your registration.", registration.OTP)