[MM-40407] - Do not show the Renew Now if the license id does not exist in the portal (#19188)
* [MM-40407] - Do not show the Renew Now if the license id does not exist in the portal * improvements * impl mock * fix translations * feedback impl * fix typo Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
34c4e543f9
Коммит
81409ee7c4
@@ -266,12 +266,19 @@ func requestRenewalLink(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
renewalLink, err := c.App.Srv().GenerateLicenseRenewalLink()
|
renewalLink, token, err := c.App.Srv().GenerateLicenseRenewalLink()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if it is possible to renew license on the portal with generated token
|
||||||
|
e := c.App.Cloud().GetLicenseRenewalStatus(c.AppContext.Session().UserId, token)
|
||||||
|
if e != nil {
|
||||||
|
c.Err = model.NewAppError("requestRenewalLink", "api.license.request_renewal_link.cannot_renew_on_cws", nil, e.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
auditRec.Success()
|
auditRec.Success()
|
||||||
c.LogAudit("success")
|
c.LogAudit("success")
|
||||||
|
|
||||||
|
|||||||
@@ -369,11 +369,11 @@ func (s *Server) renewalTokenValid(tokenString, signingKey string) (bool, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GenerateLicenseRenewalLink returns a link that points to the CWS where clients can renew license
|
// GenerateLicenseRenewalLink returns a link that points to the CWS where clients can renew license
|
||||||
func (s *Server) GenerateLicenseRenewalLink() (string, *model.AppError) {
|
func (s *Server) GenerateLicenseRenewalLink() (string, string, *model.AppError) {
|
||||||
renewalToken, err := s.GenerateRenewalToken(JWTDefaultTokenExpiration)
|
renewalToken, err := s.GenerateRenewalToken(JWTDefaultTokenExpiration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
renewalLink := LicenseRenewalURL + "?token=" + renewalToken
|
renewalLink := LicenseRenewalURL + "?token=" + renewalToken
|
||||||
return renewalLink, nil
|
return renewalLink, renewalToken, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1644,7 +1644,7 @@ func (s *Server) sendLicenseUpForRenewalEmail(users map[string]*model.User, lice
|
|||||||
|
|
||||||
daysToExpiration := license.DaysToExpiration()
|
daysToExpiration := license.DaysToExpiration()
|
||||||
|
|
||||||
renewalLink, appErr := s.GenerateLicenseRenewalLink()
|
renewalLink, _, appErr := s.GenerateLicenseRenewalLink()
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return model.NewAppError("s.sendLicenseUpForRenewalEmail", "api.server.license_up_for_renewal.error_generating_link", nil, appErr.Error(), http.StatusInternalServerError)
|
return model.NewAppError("s.sendLicenseUpForRenewalEmail", "api.server.license_up_for_renewal.error_generating_link", nil, appErr.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
@@ -1735,7 +1735,7 @@ func (s *Server) doLicenseExpirationCheck() {
|
|||||||
// SendRemoveExpiredLicenseEmail formats an email and uses the email service to send the email to user with link pointing to CWS
|
// SendRemoveExpiredLicenseEmail formats an email and uses the email service to send the email to user with link pointing to CWS
|
||||||
// to renew the user license
|
// to renew the user license
|
||||||
func (s *Server) SendRemoveExpiredLicenseEmail(email string, locale, siteURL string) *model.AppError {
|
func (s *Server) SendRemoveExpiredLicenseEmail(email string, locale, siteURL string) *model.AppError {
|
||||||
renewalLink, err := s.GenerateLicenseRenewalLink()
|
renewalLink, _, err := s.GenerateLicenseRenewalLink()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,7 @@ type CloudInterface interface {
|
|||||||
GetInvoicePDF(userID, invoiceID string) ([]byte, string, error)
|
GetInvoicePDF(userID, invoiceID string) ([]byte, string, error)
|
||||||
|
|
||||||
ChangeSubscription(userID, subscriptionID string, subscriptionChange *model.SubscriptionChange) (*model.Subscription, error)
|
ChangeSubscription(userID, subscriptionID string, subscriptionChange *model.SubscriptionChange) (*model.Subscription, error)
|
||||||
|
|
||||||
|
// GetLicenseRenewalStatus checks on the portal whether it is possible to use token to renew a license
|
||||||
|
GetLicenseRenewalStatus(userID, token string) error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,6 +173,20 @@ func (_m *CloudInterface) GetInvoicesForSubscription(userID string) ([]*model.In
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetLicenseRenewalStatus provides a mock function with given fields: userID, token
|
||||||
|
func (_m *CloudInterface) GetLicenseRenewalStatus(userID string, token string) error {
|
||||||
|
ret := _m.Called(userID, token)
|
||||||
|
|
||||||
|
var r0 error
|
||||||
|
if rf, ok := ret.Get(0).(func(string, string) error); ok {
|
||||||
|
r0 = rf(userID, token)
|
||||||
|
} else {
|
||||||
|
r0 = ret.Error(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0
|
||||||
|
}
|
||||||
|
|
||||||
// GetSubscription provides a mock function with given fields: userID
|
// GetSubscription provides a mock function with given fields: userID
|
||||||
func (_m *CloudInterface) GetSubscription(userID string) (*model.Subscription, error) {
|
func (_m *CloudInterface) GetSubscription(userID string) (*model.Subscription, error) {
|
||||||
ret := _m.Called(userID)
|
ret := _m.Called(userID)
|
||||||
|
|||||||
@@ -1953,6 +1953,10 @@
|
|||||||
"id": "api.license.request_renewal_link.app_error",
|
"id": "api.license.request_renewal_link.app_error",
|
||||||
"translation": "Error getting the license renewal link"
|
"translation": "Error getting the license renewal link"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.license.request_renewal_link.cannot_renew_on_cws",
|
||||||
|
"translation": "Renewing this license on the portal is not possible"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.license.request_trial_license.app_error",
|
"id": "api.license.request_trial_license.app_error",
|
||||||
"translation": "Unable to get a trial license, please try again or contact with support@mattermost.com."
|
"translation": "Unable to get a trial license, please try again or contact with support@mattermost.com."
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user