Add License Integration
This commit is contained in:
@@ -21,11 +21,13 @@ type AuthServiceImpl struct {
|
||||
emailSvc repository.EmailService
|
||||
emailCfg config.Email
|
||||
trxRepo repository.TransactionManager
|
||||
license repository.License
|
||||
}
|
||||
|
||||
func New(authRepo repository.Auth,
|
||||
crypto repository.Crypto, user repository.User, emailSvc repository.EmailService,
|
||||
emailCfg config.Email, trxRepo repository.TransactionManager,
|
||||
license repository.License,
|
||||
) *AuthServiceImpl {
|
||||
return &AuthServiceImpl{
|
||||
authRepo: authRepo,
|
||||
@@ -34,6 +36,7 @@ func New(authRepo repository.Auth,
|
||||
emailSvc: emailSvc,
|
||||
emailCfg: emailCfg,
|
||||
trxRepo: trxRepo,
|
||||
license: license,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +60,18 @@ func (u *AuthServiceImpl) AuthenticateUser(ctx context.Context, email, password
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var licensePartner entity.PartnerLicense
|
||||
|
||||
return user.ToUserAuthenticate(signedToken), nil
|
||||
if user.PartnerID != nil {
|
||||
parterLicense, err := u.license.FindByPartnerIDMaxEndDate(ctx, user.PartnerID)
|
||||
if err != nil {
|
||||
logger.ContextLogger(ctx).Error("error when get user license", zap.Error(err))
|
||||
return nil, errors.ErrorInternalServer
|
||||
}
|
||||
licensePartner = parterLicense.ToPartnerLicense()
|
||||
}
|
||||
|
||||
return user.ToUserAuthenticate(signedToken, licensePartner), nil
|
||||
}
|
||||
|
||||
func (u *AuthServiceImpl) SendPasswordResetLink(ctx context.Context, email string) error {
|
||||
|
||||
Reference in New Issue
Block a user