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"
|
errInvalidLogin ErrType = "User email or password is invalid"
|
||||||
errUnauthorized ErrType = "Unauthorized"
|
errUnauthorized ErrType = "Unauthorized"
|
||||||
errInsufficientBalance ErrType = "Insufficient Balance"
|
errInsufficientBalance ErrType = "Insufficient Balance"
|
||||||
|
errInactivePartner ErrType = "Partner's license is invalid or has expired. Please contact Admin Support."
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -34,6 +35,7 @@ var (
|
|||||||
ErrorUserIsNotFound = NewServiceException(errUserIsNotFound)
|
ErrorUserIsNotFound = NewServiceException(errUserIsNotFound)
|
||||||
ErrorUserInvalidLogin = NewServiceException(errInvalidLogin)
|
ErrorUserInvalidLogin = NewServiceException(errInvalidLogin)
|
||||||
ErrorInsufficientBalance = NewServiceException(errInsufficientBalance)
|
ErrorInsufficientBalance = NewServiceException(errInsufficientBalance)
|
||||||
|
ErrorInvalidLicense = NewServiceException(errInactivePartner)
|
||||||
)
|
)
|
||||||
|
|
||||||
type Error interface {
|
type Error interface {
|
||||||
@ -110,6 +112,9 @@ func (s *ServiceException) MapErrorsToCode() Code {
|
|||||||
case errInsufficientBalance:
|
case errInsufficientBalance:
|
||||||
return BadRequest
|
return BadRequest
|
||||||
|
|
||||||
|
case errInactivePartner:
|
||||||
|
return BadRequest
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return BadRequest
|
return BadRequest
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,6 +68,10 @@ type SiteParam struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *SiteParam) ToEntity(ctx mycontext.Context, partnerID *int64, siteID *int64) entity.SiteSearch {
|
func (r *SiteParam) ToEntity(ctx mycontext.Context, partnerID *int64, siteID *int64) entity.SiteSearch {
|
||||||
|
if partnerID == nil {
|
||||||
|
partnerID = r.PartnerID
|
||||||
|
}
|
||||||
|
|
||||||
return entity.SiteSearch{
|
return entity.SiteSearch{
|
||||||
PartnerID: partnerID,
|
PartnerID: partnerID,
|
||||||
IsAdmin: ctx.IsAdmin(),
|
IsAdmin: ctx.IsAdmin(),
|
||||||
|
|||||||
@ -62,13 +62,19 @@ func (u *AuthServiceImpl) AuthenticateUser(ctx context.Context, email, password
|
|||||||
var licensePartner entity.PartnerLicense
|
var licensePartner entity.PartnerLicense
|
||||||
|
|
||||||
if user.PartnerID != nil && *user.PartnerID != 0 {
|
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 {
|
if err != nil {
|
||||||
logger.ContextLogger(ctx).Error("error when get user license", zap.Error(err))
|
logger.ContextLogger(ctx).Error("error when get user license", zap.Error(err))
|
||||||
return nil, errors.ErrorInternalServer
|
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