Update License And partner
This commit is contained in:
parent
1bfbc1bccc
commit
4c8999a3cf
@ -18,6 +18,7 @@ const (
|
||||
errInvalidLogin ErrType = "User email or password is invalid"
|
||||
errUnauthorized ErrType = "Unauthorized"
|
||||
errInsufficientBalance ErrType = "Insufficient Balance"
|
||||
errInactivePartner ErrType = "Partner's license is invalid or has expired. Please contact Admin Support."
|
||||
)
|
||||
|
||||
var (
|
||||
@ -34,6 +35,7 @@ var (
|
||||
ErrorUserIsNotFound = NewServiceException(errUserIsNotFound)
|
||||
ErrorUserInvalidLogin = NewServiceException(errInvalidLogin)
|
||||
ErrorInsufficientBalance = NewServiceException(errInsufficientBalance)
|
||||
ErrorInvalidLicense = NewServiceException(errInactivePartner)
|
||||
)
|
||||
|
||||
type Error interface {
|
||||
@ -110,6 +112,9 @@ func (s *ServiceException) MapErrorsToCode() Code {
|
||||
case errInsufficientBalance:
|
||||
return BadRequest
|
||||
|
||||
case errInactivePartner:
|
||||
return BadRequest
|
||||
|
||||
default:
|
||||
return BadRequest
|
||||
}
|
||||
|
||||
@ -68,6 +68,10 @@ type SiteParam struct {
|
||||
}
|
||||
|
||||
func (r *SiteParam) ToEntity(ctx mycontext.Context, partnerID *int64, siteID *int64) entity.SiteSearch {
|
||||
if partnerID == nil {
|
||||
partnerID = r.PartnerID
|
||||
}
|
||||
|
||||
return entity.SiteSearch{
|
||||
PartnerID: partnerID,
|
||||
IsAdmin: ctx.IsAdmin(),
|
||||
|
||||
@ -62,13 +62,19 @@ func (u *AuthServiceImpl) AuthenticateUser(ctx context.Context, email, password
|
||||
var licensePartner entity.PartnerLicense
|
||||
|
||||
if user.PartnerID != nil && *user.PartnerID != 0 {
|
||||
parterLicense, err := u.license.FindByPartnerIDMaxEndDate(ctx, user.PartnerID)
|
||||
partnerLicense, 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
|
||||
}
|
||||
if parterLicense != nil {
|
||||
licensePartner = parterLicense.ToPartnerLicense()
|
||||
|
||||
if partnerLicense == nil {
|
||||
return nil, errors.ErrorInvalidLicense
|
||||
}
|
||||
|
||||
licensePartner = partnerLicense.ToPartnerLicense()
|
||||
if licensePartner.LicenseStatus == "EXPIRED" {
|
||||
return nil, errors.ErrorInvalidLicense
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user