feat: replace all panic by response err (#1993)

* fix: missing return after response error

* feat: handle error in frontend

* feat: disable loading and catch org edit error

* chore: i18 for error message

* chore: remove break line

* feat: application catching error
This commit is contained in:
Trần Thanh Tịnh 2023-06-27 20:33:47 +07:00 committed by GitHub
parent 0a8c2a35fe
commit cd7589775c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 416 additions and 155 deletions

View File

@ -50,7 +50,8 @@ func (c *ApiController) GetApplications() {
} }
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = object.GetMaskedApplications(applications, userId) c.Data["json"] = object.GetMaskedApplications(applications, userId)
@ -59,13 +60,15 @@ func (c *ApiController) GetApplications() {
limit := util.ParseInt(limit) limit := util.ParseInt(limit)
count, err := object.GetApplicationCount(owner, field, value) count, err := object.GetApplicationCount(owner, field, value)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
paginator := pagination.SetPaginator(c.Ctx, limit, count) paginator := pagination.SetPaginator(c.Ctx, limit, count)
app, err := object.GetPaginationApplications(owner, paginator.Offset(), limit, field, value, sortField, sortOrder) app, err := object.GetPaginationApplications(owner, paginator.Offset(), limit, field, value, sortField, sortOrder)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
applications := object.GetMaskedApplications(app, userId) applications := object.GetMaskedApplications(app, userId)
@ -85,7 +88,8 @@ func (c *ApiController) GetApplication() {
id := c.Input().Get("id") id := c.Input().Get("id")
app, err := object.GetApplication(id) app, err := object.GetApplication(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = object.GetMaskedApplication(app, userId) c.Data["json"] = object.GetMaskedApplication(app, userId)
@ -104,7 +108,8 @@ func (c *ApiController) GetUserApplication() {
id := c.Input().Get("id") id := c.Input().Get("id")
user, err := object.GetUser(id) user, err := object.GetUser(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
if user == nil { if user == nil {
@ -114,7 +119,8 @@ func (c *ApiController) GetUserApplication() {
app, err := object.GetApplicationByUser(user) app, err := object.GetApplicationByUser(user)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = object.GetMaskedApplication(app, userId) c.Data["json"] = object.GetMaskedApplication(app, userId)
@ -147,7 +153,8 @@ func (c *ApiController) GetOrganizationApplications() {
if limit == "" || page == "" { if limit == "" || page == "" {
applications, err := object.GetOrganizationApplications(owner, organization) applications, err := object.GetOrganizationApplications(owner, organization)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = object.GetMaskedApplications(applications, userId) c.Data["json"] = object.GetMaskedApplications(applications, userId)

View File

@ -756,7 +756,8 @@ func (c *ApiController) HandleSamlLogin() {
func (c *ApiController) HandleOfficialAccountEvent() { func (c *ApiController) HandleOfficialAccountEvent() {
respBytes, err := ioutil.ReadAll(c.Ctx.Request.Body) respBytes, err := ioutil.ReadAll(c.Ctx.Request.Body)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
var data struct { var data struct {
@ -766,7 +767,8 @@ func (c *ApiController) HandleOfficialAccountEvent() {
} }
err = xml.Unmarshal(respBytes, &data) err = xml.Unmarshal(respBytes, &data)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
lock.Lock() lock.Lock()

View File

@ -79,7 +79,8 @@ func (c *ApiController) getCurrentUser() *object.User {
} else { } else {
user, err = object.GetUser(userId) user, err = object.GetUser(userId)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return nil
} }
} }
return user return user
@ -112,7 +113,8 @@ func (c *ApiController) GetSessionApplication() *object.Application {
} }
application, err := object.GetApplicationByClientId(clientId.(string)) application, err := object.GetApplicationByClientId(clientId.(string))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return nil
} }
return application return application

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetCerts() {
if limit == "" || page == "" { if limit == "" || page == "" {
maskedCerts, err := object.GetMaskedCerts(object.GetCerts(owner)) maskedCerts, err := object.GetMaskedCerts(object.GetCerts(owner))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = maskedCerts c.Data["json"] = maskedCerts
@ -50,13 +51,15 @@ func (c *ApiController) GetCerts() {
limit := util.ParseInt(limit) limit := util.ParseInt(limit)
count, err := object.GetCertCount(owner, field, value) count, err := object.GetCertCount(owner, field, value)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
paginator := pagination.SetPaginator(c.Ctx, limit, count) paginator := pagination.SetPaginator(c.Ctx, limit, count)
certs, err := object.GetMaskedCerts(object.GetPaginationCerts(owner, paginator.Offset(), limit, field, value, sortField, sortOrder)) certs, err := object.GetMaskedCerts(object.GetPaginationCerts(owner, paginator.Offset(), limit, field, value, sortField, sortOrder))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.ResponseOk(certs, paginator.Nums()) c.ResponseOk(certs, paginator.Nums())
@ -80,7 +83,8 @@ func (c *ApiController) GetGlobleCerts() {
if limit == "" || page == "" { if limit == "" || page == "" {
maskedCerts, err := object.GetMaskedCerts(object.GetGlobleCerts()) maskedCerts, err := object.GetMaskedCerts(object.GetGlobleCerts())
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = maskedCerts c.Data["json"] = maskedCerts
@ -89,13 +93,15 @@ func (c *ApiController) GetGlobleCerts() {
limit := util.ParseInt(limit) limit := util.ParseInt(limit)
count, err := object.GetGlobalCertsCount(field, value) count, err := object.GetGlobalCertsCount(field, value)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
paginator := pagination.SetPaginator(c.Ctx, limit, count) paginator := pagination.SetPaginator(c.Ctx, limit, count)
certs, err := object.GetMaskedCerts(object.GetPaginationGlobalCerts(paginator.Offset(), limit, field, value, sortField, sortOrder)) certs, err := object.GetMaskedCerts(object.GetPaginationGlobalCerts(paginator.Offset(), limit, field, value, sortField, sortOrder))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.ResponseOk(certs, paginator.Nums()) c.ResponseOk(certs, paginator.Nums())
@ -113,7 +119,8 @@ func (c *ApiController) GetCert() {
id := c.Input().Get("id") id := c.Input().Get("id")
cert, err := object.GetCert(id) cert, err := object.GetCert(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = object.GetMaskedCert(cert) c.Data["json"] = object.GetMaskedCert(cert)

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetChats() {
if limit == "" || page == "" { if limit == "" || page == "" {
maskedChats, err := object.GetMaskedChats(object.GetChats(owner)) maskedChats, err := object.GetMaskedChats(object.GetChats(owner))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = maskedChats c.Data["json"] = maskedChats
@ -77,7 +78,8 @@ func (c *ApiController) GetChat() {
maskedChat, err := object.GetMaskedChat(object.GetChat(id)) maskedChat, err := object.GetMaskedChat(object.GetChat(id))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = maskedChat c.Data["json"] = maskedChat

View File

@ -53,7 +53,8 @@ func (c *ApiController) GetMessages() {
} }
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = object.GetMaskedMessages(messages) c.Data["json"] = object.GetMaskedMessages(messages)
@ -89,7 +90,8 @@ func (c *ApiController) GetMessage() {
id := c.Input().Get("id") id := c.Input().Get("id")
message, err := object.GetMessage(id) message, err := object.GetMessage(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = object.GetMaskedMessage(message) c.Data["json"] = object.GetMaskedMessage(message)
@ -100,7 +102,8 @@ func (c *ApiController) ResponseErrorStream(errorText string) {
event := fmt.Sprintf("event: myerror\ndata: %s\n\n", errorText) event := fmt.Sprintf("event: myerror\ndata: %s\n\n", errorText)
_, err := c.Ctx.ResponseWriter.Write([]byte(event)) _, err := c.Ctx.ResponseWriter.Write([]byte(event))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
} }
@ -196,7 +199,8 @@ func (c *ApiController) GetMessageAnswer() {
event := fmt.Sprintf("event: end\ndata: %s\n\n", "end") event := fmt.Sprintf("event: end\ndata: %s\n\n", "end")
_, err = c.Ctx.ResponseWriter.Write([]byte(event)) _, err = c.Ctx.ResponseWriter.Write([]byte(event))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
answer := stringBuilder.String() answer := stringBuilder.String()
@ -204,7 +208,8 @@ func (c *ApiController) GetMessageAnswer() {
message.Text = answer message.Text = answer
_, err = object.UpdateMessage(message.GetId(), message) _, err = object.UpdateMessage(message.GetId(), message)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
} }

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetModels() {
if limit == "" || page == "" { if limit == "" || page == "" {
models, err := object.GetModels(owner) models, err := object.GetModels(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = models c.Data["json"] = models
@ -77,7 +78,8 @@ func (c *ApiController) GetModel() {
model, err := object.GetModel(id) model, err := object.GetModel(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = model c.Data["json"] = model

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetOrganizations() {
if limit == "" || page == "" { if limit == "" || page == "" {
maskedOrganizations, err := object.GetMaskedOrganizations(object.GetOrganizations(owner)) maskedOrganizations, err := object.GetMaskedOrganizations(object.GetOrganizations(owner))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = maskedOrganizations c.Data["json"] = maskedOrganizations

View File

@ -42,7 +42,8 @@ func (c *ApiController) GetPayments() {
if limit == "" || page == "" { if limit == "" || page == "" {
payments, err := object.GetPayments(owner) payments, err := object.GetPayments(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = payments c.Data["json"] = payments
@ -51,13 +52,15 @@ func (c *ApiController) GetPayments() {
limit := util.ParseInt(limit) limit := util.ParseInt(limit)
count, err := object.GetPaymentCount(owner, organization, field, value) count, err := object.GetPaymentCount(owner, organization, field, value)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
paginator := pagination.SetPaginator(c.Ctx, limit, count) paginator := pagination.SetPaginator(c.Ctx, limit, count)
payments, err := object.GetPaginationPayments(owner, organization, paginator.Offset(), limit, field, value, sortField, sortOrder) payments, err := object.GetPaginationPayments(owner, organization, paginator.Offset(), limit, field, value, sortField, sortOrder)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.ResponseOk(payments, paginator.Nums()) c.ResponseOk(payments, paginator.Nums())
@ -99,7 +102,8 @@ func (c *ApiController) GetPayment() {
payment, err := object.GetPayment(id) payment, err := object.GetPayment(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = payment c.Data["json"] = payment
@ -190,7 +194,8 @@ func (c *ApiController) NotifyPayment() {
} }
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
} }

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetPermissions() {
if limit == "" || page == "" { if limit == "" || page == "" {
permissions, err := object.GetPermissions(owner) permissions, err := object.GetPermissions(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = permissions c.Data["json"] = permissions
@ -50,13 +51,15 @@ func (c *ApiController) GetPermissions() {
limit := util.ParseInt(limit) limit := util.ParseInt(limit)
count, err := object.GetPermissionCount(owner, field, value) count, err := object.GetPermissionCount(owner, field, value)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
paginator := pagination.SetPaginator(c.Ctx, limit, count) paginator := pagination.SetPaginator(c.Ctx, limit, count)
permissions, err := object.GetPaginationPermissions(owner, paginator.Offset(), limit, field, value, sortField, sortOrder) permissions, err := object.GetPaginationPermissions(owner, paginator.Offset(), limit, field, value, sortField, sortOrder)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.ResponseOk(permissions, paginator.Nums()) c.ResponseOk(permissions, paginator.Nums())
@ -116,7 +119,8 @@ func (c *ApiController) GetPermission() {
permission, err := object.GetPermission(id) permission, err := object.GetPermission(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = permission c.Data["json"] = permission

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetPlans() {
if limit == "" || page == "" { if limit == "" || page == "" {
plans, err := object.GetPlans(owner) plans, err := object.GetPlans(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = plans c.Data["json"] = plans
@ -79,13 +80,15 @@ func (c *ApiController) GetPlan() {
plan, err := object.GetPlan(id) plan, err := object.GetPlan(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
if includeOption { if includeOption {
options, err := object.GetPermissionsByRole(plan.Role) options, err := object.GetPermissionsByRole(plan.Role)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
for _, option := range options { for _, option := range options {

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetPricings() {
if limit == "" || page == "" { if limit == "" || page == "" {
pricings, err := object.GetPricings(owner) pricings, err := object.GetPricings(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = pricings c.Data["json"] = pricings
@ -77,7 +78,8 @@ func (c *ApiController) GetPricing() {
pricing, err := object.GetPricing(id) pricing, err := object.GetPricing(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = pricing c.Data["json"] = pricing

View File

@ -42,7 +42,8 @@ func (c *ApiController) GetProducts() {
if limit == "" || page == "" { if limit == "" || page == "" {
products, err := object.GetProducts(owner) products, err := object.GetProducts(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = products c.Data["json"] = products
@ -78,12 +79,14 @@ func (c *ApiController) GetProduct() {
product, err := object.GetProduct(id) product, err := object.GetProduct(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
err = object.ExtendProductWithProviders(product) err = object.ExtendProductWithProviders(product)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = product c.Data["json"] = product

View File

@ -46,7 +46,8 @@ func (c *ApiController) GetProviders() {
if limit == "" || page == "" { if limit == "" || page == "" {
providers, err := object.GetProviders(owner) providers, err := object.GetProviders(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.ResponseOk(object.GetMaskedProviders(providers, isMaskEnabled)) c.ResponseOk(object.GetMaskedProviders(providers, isMaskEnabled))
@ -92,7 +93,8 @@ func (c *ApiController) GetGlobalProviders() {
if limit == "" || page == "" { if limit == "" || page == "" {
globalProviders, err := object.GetGlobalProviders() globalProviders, err := object.GetGlobalProviders()
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.ResponseOk(object.GetMaskedProviders(globalProviders, isMaskEnabled)) c.ResponseOk(object.GetMaskedProviders(globalProviders, isMaskEnabled))

View File

@ -46,7 +46,8 @@ func (c *ApiController) GetRecords() {
if limit == "" || page == "" { if limit == "" || page == "" {
records, err := object.GetRecords() records, err := object.GetRecords()
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = records c.Data["json"] = records
@ -84,12 +85,14 @@ func (c *ApiController) GetRecordsByFilter() {
record := &object.Record{} record := &object.Record{}
err := util.JsonToStruct(body, record) err := util.JsonToStruct(body, record)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
records, err := object.GetRecordsByField(record) records, err := object.GetRecordsByField(record)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = records c.Data["json"] = records

View File

@ -53,7 +53,8 @@ func (c *ApiController) GetResources() {
if limit == "" || page == "" { if limit == "" || page == "" {
resources, err := object.GetResources(owner, user) resources, err := object.GetResources(owner, user)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = resources c.Data["json"] = resources
@ -86,7 +87,8 @@ func (c *ApiController) GetResource() {
resource, err := object.GetResource(id) resource, err := object.GetResource(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = resource c.Data["json"] = resource

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetRoles() {
if limit == "" || page == "" { if limit == "" || page == "" {
roles, err := object.GetRoles(owner) roles, err := object.GetRoles(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = roles c.Data["json"] = roles
@ -77,7 +78,8 @@ func (c *ApiController) GetRole() {
role, err := object.GetRole(id) role, err := object.GetRole(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = role c.Data["json"] = role

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetSessions() {
if limit == "" || page == "" { if limit == "" || page == "" {
sessions, err := object.GetSessions(owner) sessions, err := object.GetSessions(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = sessions c.Data["json"] = sessions
@ -76,7 +77,8 @@ func (c *ApiController) GetSingleSession() {
session, err := object.GetSingleSession(id) session, err := object.GetSingleSession(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = session c.Data["json"] = session
@ -155,7 +157,8 @@ func (c *ApiController) IsSessionDuplicated() {
isUserSessionDuplicated, err := object.IsSessionDuplicated(id, sessionId) isUserSessionDuplicated, err := object.IsSessionDuplicated(id, sessionId)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = &Response{Status: "ok", Msg: "", Data: isUserSessionDuplicated} c.Data["json"] = &Response{Status: "ok", Msg: "", Data: isUserSessionDuplicated}

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetSubscriptions() {
if limit == "" || page == "" { if limit == "" || page == "" {
subscriptions, err := object.GetSubscriptions(owner) subscriptions, err := object.GetSubscriptions(owner)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = subscriptions c.Data["json"] = subscriptions
@ -77,7 +78,8 @@ func (c *ApiController) GetSubscription() {
subscription, err := object.GetSubscription(id) subscription, err := object.GetSubscription(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = subscription c.Data["json"] = subscription

View File

@ -42,7 +42,8 @@ func (c *ApiController) GetSyncers() {
if limit == "" || page == "" { if limit == "" || page == "" {
organizationSyncers, err := object.GetOrganizationSyncers(owner, organization) organizationSyncers, err := object.GetOrganizationSyncers(owner, organization)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = organizationSyncers c.Data["json"] = organizationSyncers
@ -78,7 +79,8 @@ func (c *ApiController) GetSyncer() {
syncer, err := object.GetSyncer(id) syncer, err := object.GetSyncer(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = syncer c.Data["json"] = syncer

View File

@ -43,7 +43,8 @@ func (c *ApiController) GetTokens() {
if limit == "" || page == "" { if limit == "" || page == "" {
token, err := object.GetTokens(owner, organization) token, err := object.GetTokens(owner, organization)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = token c.Data["json"] = token
@ -78,7 +79,8 @@ func (c *ApiController) GetToken() {
id := c.Input().Get("id") id := c.Input().Get("id")
token, err := object.GetToken(id) token, err := object.GetToken(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = token c.Data["json"] = token
@ -193,7 +195,8 @@ func (c *ApiController) GetOAuthToken() {
host := c.Ctx.Request.Host host := c.Ctx.Request.Host
oAuthtoken, err := object.GetOAuthToken(grantType, clientId, clientSecret, code, verifier, scope, username, password, host, refreshToken, tag, avatar, c.GetAcceptLanguage()) oAuthtoken, err := object.GetOAuthToken(grantType, clientId, clientSecret, code, verifier, scope, username, password, host, refreshToken, tag, avatar, c.GetAcceptLanguage())
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = oAuthtoken c.Data["json"] = oAuthtoken
@ -236,7 +239,8 @@ func (c *ApiController) RefreshToken() {
refreshToken2, err := object.RefreshToken(grantType, refreshToken, scope, clientId, clientSecret, host) refreshToken2, err := object.RefreshToken(grantType, refreshToken, scope, clientId, clientSecret, host)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = refreshToken2 c.Data["json"] = refreshToken2
@ -276,7 +280,8 @@ func (c *ApiController) IntrospectToken() {
} }
application, err := object.GetApplicationByClientId(clientId) application, err := object.GetApplicationByClientId(clientId)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
if application == nil || application.ClientSecret != clientSecret { if application == nil || application.ClientSecret != clientSecret {
@ -289,7 +294,8 @@ func (c *ApiController) IntrospectToken() {
} }
token, err := object.GetTokenByTokenAndApplication(tokenValue, application.Name) token, err := object.GetTokenByTokenAndApplication(tokenValue, application.Name)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
if token == nil { if token == nil {

View File

@ -41,7 +41,8 @@ func (c *ApiController) GetGlobalUsers() {
if limit == "" || page == "" { if limit == "" || page == "" {
maskedUsers, err := object.GetMaskedUsers(object.GetGlobalUsers()) maskedUsers, err := object.GetMaskedUsers(object.GetGlobalUsers())
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = maskedUsers c.Data["json"] = maskedUsers
@ -101,7 +102,8 @@ func (c *ApiController) GetUsers() {
maskedUsers, err := object.GetMaskedUsers(object.GetUsers(owner)) maskedUsers, err := object.GetMaskedUsers(object.GetUsers(owner))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = maskedUsers c.Data["json"] = maskedUsers
@ -153,7 +155,8 @@ func (c *ApiController) GetUser() {
if userId != "" && owner != "" { if userId != "" && owner != "" {
userFromUserId, err = object.GetUserByUserId(owner, userId) userFromUserId, err = object.GetUserByUserId(owner, userId)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
id = util.GetId(userFromUserId.Owner, userFromUserId.Name) id = util.GetId(userFromUserId.Owner, userFromUserId.Name)
@ -165,7 +168,8 @@ func (c *ApiController) GetUser() {
organization, err := object.GetOrganization(util.GetId("admin", owner)) organization, err := object.GetOrganization(util.GetId("admin", owner))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
if !organization.IsProfilePublic { if !organization.IsProfilePublic {
@ -190,18 +194,21 @@ func (c *ApiController) GetUser() {
} }
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
user.MultiFactorAuths = object.GetAllMfaProps(user, true) user.MultiFactorAuths = object.GetAllMfaProps(user, true)
err = object.ExtendUserWithRolesAndPermissions(user) err = object.ExtendUserWithRolesAndPermissions(user)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
maskedUser, err := object.GetMaskedUser(user) maskedUser, err := object.GetMaskedUser(user)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = maskedUser c.Data["json"] = maskedUser
@ -498,7 +505,8 @@ func (c *ApiController) GetSortedUsers() {
maskedUsers, err := object.GetMaskedUsers(object.GetSortedUsers(owner, sorter, limit)) maskedUsers, err := object.GetMaskedUsers(object.GetSortedUsers(owner, sorter, limit))
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = maskedUsers c.Data["json"] = maskedUsers

View File

@ -97,7 +97,8 @@ func (c *ApiController) RequireSignedInUser() (*object.User, bool) {
user, err := object.GetUser(userId) user, err := object.GetUser(userId)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return nil, false
} }
if user == nil { if user == nil {

View File

@ -42,7 +42,8 @@ func (c *ApiController) GetWebhooks() {
if limit == "" || page == "" { if limit == "" || page == "" {
webhooks, err := object.GetWebhooks(owner, organization) webhooks, err := object.GetWebhooks(owner, organization)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = webhooks c.Data["json"] = webhooks
@ -79,7 +80,8 @@ func (c *ApiController) GetWebhook() {
webhook, err := object.GetWebhook(id) webhook, err := object.GetWebhook(id)
if err != nil { if err != nil {
panic(err) c.ResponseError(err.Error())
return
} }
c.Data["json"] = webhook c.Data["json"] = webhook

View File

@ -76,6 +76,10 @@ class AdapterEditPage extends React.Component {
getModels(organizationName) { getModels(organizationName) {
ModelBackend.getModels(organizationName) ModelBackend.getModels(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
models: res, models: res,
}); });

View File

@ -118,20 +118,25 @@ class ApplicationEditPage extends React.Component {
getApplication() { getApplication() {
ApplicationBackend.getApplication("admin", this.state.applicationName) ApplicationBackend.getApplication("admin", this.state.applicationName)
.then((application) => { .then((res) => {
if (application === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (application.grantTypes === null || application.grantTypes === undefined || application.grantTypes.length === 0) { if (res.status === "error") {
application.grantTypes = ["authorization_code"]; Setting.showMessage("error", res.msg);
return;
}
if (res.grantTypes === null || res.grantTypes === undefined || res.grantTypes.length === 0) {
res.grantTypes = ["authorization_code"];
} }
this.setState({ this.setState({
application: application, application: res,
}); });
this.getCerts(application.organization); this.getCerts(res.organization);
}); });
} }

View File

@ -44,14 +44,19 @@ class CertEditPage extends React.Component {
getCert() { getCert() {
CertBackend.getCert(this.state.owner, this.state.certName) CertBackend.getCert(this.state.owner, this.state.certName)
.then((cert) => { .then((res) => {
if (cert === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
cert: cert, cert: res,
}); });
}); });
} }

View File

@ -40,17 +40,21 @@ class ChatEditPage extends React.Component {
getChat() { getChat() {
ChatBackend.getChat("admin", this.state.chatName) ChatBackend.getChat("admin", this.state.chatName)
.then((chat) => { .then((res) => {
if (chat === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
chat: chat, chat: res,
}); });
this.getUsers(chat.organization); this.getUsers(res.organization);
}); });
} }
@ -66,6 +70,11 @@ class ChatEditPage extends React.Component {
getUsers(organizationName) { getUsers(organizationName) {
UserBackend.getUsers(organizationName) UserBackend.getUsers(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
users: res, users: res,
}); });

View File

@ -74,8 +74,12 @@ class EntryPage extends React.Component {
}); });
ApplicationBackend.getApplication("admin", pricing.application) ApplicationBackend.getApplication("admin", pricing.application)
.then((application) => { .then((res) => {
const themeData = application !== null ? Setting.getThemeData(application.organizationObj, application) : Conf.ThemeDefault; if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
const themeData = res !== null ? Setting.getThemeData(res.organizationObj, res) : Conf.ThemeDefault;
this.props.updataThemeData(themeData); this.props.updataThemeData(themeData);
}); });
}; };

View File

@ -45,17 +45,20 @@ class MessageEditPage extends React.Component {
getMessage() { getMessage() {
MessageBackend.getMessage("admin", this.state.messageName) MessageBackend.getMessage("admin", this.state.messageName)
.then((message) => { .then((res) => {
if (message === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
message: message, message: res,
}); });
this.getUsers(message.organization); this.getUsers(res.organization);
}); });
} }
@ -80,6 +83,10 @@ class MessageEditPage extends React.Component {
getUsers(organizationName) { getUsers(organizationName) {
UserBackend.getUsers(organizationName) UserBackend.getUsers(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
users: res, users: res,
}); });

View File

@ -47,14 +47,19 @@ class ModelEditPage extends React.Component {
getModel() { getModel() {
ModelBackend.getModel(this.state.organizationName, this.state.modelName) ModelBackend.getModel(this.state.organizationName, this.state.modelName)
.then((model) => { .then((res) => {
if (model === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
model: model, model: res,
}); });
}); });
} }

View File

@ -68,9 +68,14 @@ class OrganizationEditPage extends React.Component {
getApplications() { getApplications() {
ApplicationBackend.getApplicationsByOrganization("admin", this.state.organizationName) ApplicationBackend.getApplicationsByOrganization("admin", this.state.organizationName)
.then((applications) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
applications: applications, applications: res,
}); });
}); });
} }

View File

@ -49,21 +49,26 @@ class PermissionEditPage extends React.Component {
getPermission() { getPermission() {
PermissionBackend.getPermission(this.state.organizationName, this.state.permissionName) PermissionBackend.getPermission(this.state.organizationName, this.state.permissionName)
.then((permission) => { .then((res) => {
if (permission === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
permission: permission, permission: res,
}); });
this.getUsers(permission.owner); this.getUsers(res.owner);
this.getRoles(permission.owner); this.getRoles(res.owner);
this.getModels(permission.owner); this.getModels(res.owner);
this.getResources(permission.owner); this.getResources(res.owner);
this.getModel(permission.owner, permission.model); this.getModel(res.owner, res.model);
}); });
} }
@ -79,6 +84,10 @@ class PermissionEditPage extends React.Component {
getUsers(organizationName) { getUsers(organizationName) {
UserBackend.getUsers(organizationName) UserBackend.getUsers(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
users: res, users: res,
}); });
@ -88,6 +97,10 @@ class PermissionEditPage extends React.Component {
getRoles(organizationName) { getRoles(organizationName) {
RoleBackend.getRoles(organizationName) RoleBackend.getRoles(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
roles: res, roles: res,
}); });
@ -97,6 +110,10 @@ class PermissionEditPage extends React.Component {
getModels(organizationName) { getModels(organizationName) {
ModelBackend.getModels(organizationName) ModelBackend.getModels(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
models: res, models: res,
}); });
@ -106,6 +123,10 @@ class PermissionEditPage extends React.Component {
getModel(organizationName, modelName) { getModel(organizationName, modelName) {
ModelBackend.getModel(organizationName, modelName) ModelBackend.getModel(organizationName, modelName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
model: res, model: res,
}); });

View File

@ -64,6 +64,10 @@ class PlanEditPage extends React.Component {
getRoles(organizationName) { getRoles(organizationName) {
RoleBackend.getRoles(organizationName) RoleBackend.getRoles(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
roles: res, roles: res,
}); });
@ -73,6 +77,10 @@ class PlanEditPage extends React.Component {
getUsers(organizationName) { getUsers(organizationName) {
UserBackend.getUsers(organizationName) UserBackend.getUsers(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
users: res, users: res,
}); });

View File

@ -49,22 +49,31 @@ class PricingEditPage extends React.Component {
getPricing() { getPricing() {
PricingBackend.getPricing(this.state.organizationName, this.state.pricingName) PricingBackend.getPricing(this.state.organizationName, this.state.pricingName)
.then((pricing) => { .then((res) => {
if (pricing === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
pricing: pricing, pricing: res,
}); });
this.getPlans(pricing.owner); this.getPlans(res.owner);
}); });
} }
getPlans(organizationName) { getPlans(organizationName) {
PlanBackend.getPlans(organizationName) PlanBackend.getPlans(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
plans: res, plans: res,
}); });
@ -109,9 +118,13 @@ class PricingEditPage extends React.Component {
getUserApplication() { getUserApplication() {
ApplicationBackend.getUserApplication(this.state.organizationName, this.state.userName) ApplicationBackend.getUserApplication(this.state.organizationName, this.state.userName)
.then((application) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
application: application, application: res,
}); });
}); });
} }

View File

@ -41,9 +41,14 @@ class ProductBuyPage extends React.Component {
} }
ProductBackend.getProduct(this.props.account.owner, this.state.productName) ProductBackend.getProduct(this.props.account.owner, this.state.productName)
.then((product) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
product: product, product: res,
}); });
}); });
} }

View File

@ -42,18 +42,22 @@ class RoleEditPage extends React.Component {
getRole() { getRole() {
RoleBackend.getRole(this.state.organizationName, this.state.roleName) RoleBackend.getRole(this.state.organizationName, this.state.roleName)
.then((role) => { .then((res) => {
if (role === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
role: role, role: res,
}); });
this.getUsers(role.owner); this.getUsers(res.owner);
this.getRoles(role.owner); this.getRoles(res.owner);
}); });
} }
@ -69,6 +73,10 @@ class RoleEditPage extends React.Component {
getUsers(organizationName) { getUsers(organizationName) {
UserBackend.getUsers(organizationName) UserBackend.getUsers(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
users: res, users: res,
}); });
@ -78,6 +86,10 @@ class RoleEditPage extends React.Component {
getRoles(organizationName) { getRoles(organizationName) {
RoleBackend.getRoles(organizationName) RoleBackend.getRoles(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
roles: res, roles: res,
}); });

View File

@ -46,18 +46,23 @@ class SubscriptionEditPage extends React.Component {
getSubscription() { getSubscription() {
SubscriptionBackend.getSubscription(this.state.organizationName, this.state.subscriptionName) SubscriptionBackend.getSubscription(this.state.organizationName, this.state.subscriptionName)
.then((subscription) => { .then((res) => {
if (subscription === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
subscription: subscription, subscription: res,
}); });
this.getUsers(subscription.owner); this.getUsers(res.owner);
this.getPlanes(subscription.owner); this.getPlanes(res.owner);
}); });
} }
@ -73,6 +78,10 @@ class SubscriptionEditPage extends React.Component {
getUsers(organizationName) { getUsers(organizationName) {
UserBackend.getUsers(organizationName) UserBackend.getUsers(organizationName)
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
users: res, users: res,
}); });

View File

@ -47,14 +47,19 @@ class SyncerEditPage extends React.Component {
getSyncer() { getSyncer() {
SyncerBackend.getSyncer("admin", this.state.syncerName) SyncerBackend.getSyncer("admin", this.state.syncerName)
.then((syncer) => { .then((res) => {
if (syncer === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
syncer: syncer, syncer: res,
}); });
}); });
} }

View File

@ -35,14 +35,19 @@ class TokenEditPage extends React.Component {
getToken() { getToken() {
TokenBackend.getToken("admin", this.state.tokenName) TokenBackend.getToken("admin", this.state.tokenName)
.then((token) => { .then((res) => {
if (token === null) { if (res === null) {
this.props.history.push("/404"); this.props.history.push("/404");
return; return;
} }
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
token: token, token: res,
}); });
}); });
} }

View File

@ -121,13 +121,17 @@ class UserEditPage extends React.Component {
getUserApplication() { getUserApplication() {
ApplicationBackend.getUserApplication(this.state.organizationName, this.state.userName) ApplicationBackend.getUserApplication(this.state.organizationName, this.state.userName)
.then((application) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
application: application, application: res,
}); });
this.setState({ this.setState({
isGroupsVisible: application.organizationObj.accountItems?.some((item) => item.name === "Groups" && item.visible), isGroupsVisible: res.organizationObj.accountItems?.some((item) => item.name === "Groups" && item.visible),
}); });
}); });
} }

View File

@ -63,8 +63,12 @@ class ForgetPage extends React.Component {
} }
ApplicationBackend.getApplication("admin", this.state.applicationName) ApplicationBackend.getApplication("admin", this.state.applicationName)
.then((application) => { .then((res) => {
this.onUpdateApplication(application); if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.onUpdateApplication(res);
}); });
} }
getApplicationObj() { getApplicationObj() {

View File

@ -159,8 +159,12 @@ class LoginPage extends React.Component {
if (this.state.owner === null || this.state.type === "saml") { if (this.state.owner === null || this.state.type === "saml") {
ApplicationBackend.getApplication("admin", this.state.applicationName) ApplicationBackend.getApplication("admin", this.state.applicationName)
.then((application) => { .then((res) => {
this.onUpdateApplication(application); if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.onUpdateApplication(res);
}); });
} else { } else {
OrganizationBackend.getDefaultApplication("admin", this.state.owner) OrganizationBackend.getDefaultApplication("admin", this.state.owner)

View File

@ -188,10 +188,14 @@ class MfaSetupPage extends React.Component {
} }
ApplicationBackend.getApplication("admin", this.state.applicationName) ApplicationBackend.getApplication("admin", this.state.applicationName)
.then((application) => { .then((res) => {
if (application !== null) { if (res !== null) {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
application: application, application: res,
}); });
} else { } else {
Setting.showMessage("error", i18next.t("mfa:Failed to get application")); Setting.showMessage("error", i18next.t("mfa:Failed to get application"));

View File

@ -49,9 +49,14 @@ class PromptPage extends React.Component {
const organizationName = this.props.account.owner; const organizationName = this.props.account.owner;
const userName = this.props.account.name; const userName = this.props.account.name;
UserBackend.getUser(organizationName, userName) UserBackend.getUser(organizationName, userName)
.then((user) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.setState({ this.setState({
user: user, user: res,
}); });
}); });
} }
@ -62,10 +67,15 @@ class PromptPage extends React.Component {
} }
ApplicationBackend.getApplication("admin", this.state.applicationName) ApplicationBackend.getApplication("admin", this.state.applicationName)
.then((application) => { .then((res) => {
this.onUpdateApplication(application); if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.onUpdateApplication(res);
this.setState({ this.setState({
application: application, application: res,
}); });
}); });
} }

View File

@ -43,10 +43,14 @@ class ResultPage extends React.Component {
} }
ApplicationBackend.getApplication("admin", this.state.applicationName) ApplicationBackend.getApplication("admin", this.state.applicationName)
.then((application) => { .then((res) => {
this.onUpdateApplication(application); if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.onUpdateApplication(res);
this.setState({ this.setState({
application: application, application: res,
}); });
}); });
} }

View File

@ -108,8 +108,13 @@ class SignupPage extends React.Component {
} }
ApplicationBackend.getApplication("admin", applicationName) ApplicationBackend.getApplication("admin", applicationName)
.then((application) => { .then((res) => {
this.onUpdateApplication(application); if (res.status === "error") {
Setting.showMessage("error", res.msg);
return;
}
this.onUpdateApplication(res);
}); });
} }

View File

@ -127,6 +127,11 @@ export const CropperDivModal = (props) => {
setLoading(true); setLoading(true);
ResourceBackend.getResources(user.owner, user.name, "", "", "", "", "", "") ResourceBackend.getResources(user.owner, user.name, "", "", "", "", "", "")
.then((res) => { .then((res) => {
if (res.status === "error") {
Setting.showMessage("error", res.msg);
setLoading(false);
return;
}
setLoading(false); setLoading(false);
setOptions(getOptions(res)); setOptions(getOptions(res));
}); });

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "Preisseite URL kopieren", "Copy pricing page URL": "Preisseite URL kopieren",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "Kostenlos", "Free": "Kostenlos",
"Failed to get plans": "Es konnten keine Pläne abgerufen werden",
"Getting started": "Loslegen", "Getting started": "Loslegen",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "Testphase Dauer", "Trial duration": "Testphase Dauer",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "Copy pricing page URL", "Copy pricing page URL": "Copy pricing page URL",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "Free", "Free": "Free",
"Failed to get plans": "Failed to get plans",
"Getting started": "Getting started", "Getting started": "Getting started",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "Trial duration", "Trial duration": "Trial duration",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "Copiar URL de la página de precios", "Copy pricing page URL": "Copiar URL de la página de precios",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "Gratis", "Free": "Gratis",
"Failed to get plans": "No se pudieron obtener los planes",
"Getting started": "Empezar", "Getting started": "Empezar",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "Duración del período de prueba", "Trial duration": "Duración del período de prueba",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "Copier l'URL de la page tarifs", "Copy pricing page URL": "Copier l'URL de la page tarifs",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "Gratuit", "Free": "Gratuit",
"Failed to get plans": "Échec de l'obtention des plans",
"Getting started": "Commencer", "Getting started": "Commencer",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "Durée de l'essai", "Trial duration": "Durée de l'essai",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "Salin URL halaman harga", "Copy pricing page URL": "Salin URL halaman harga",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "Gratis", "Free": "Gratis",
"Failed to get plans": "Gagal mendapatkan rencana",
"Getting started": "Mulai", "Getting started": "Mulai",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "Durasi percobaan", "Trial duration": "Durasi percobaan",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "価格ページのURLをコピー", "Copy pricing page URL": "価格ページのURLをコピー",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "無料", "Free": "無料",
"Failed to get plans": "計画の取得に失敗しました",
"Getting started": "はじめる", "Getting started": "はじめる",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "トライアル期間の長さ", "Trial duration": "トライアル期間の長さ",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "가격 페이지 URL 복사", "Copy pricing page URL": "가격 페이지 URL 복사",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "무료", "Free": "무료",
"Failed to get plans": "계획을 가져오지 못했습니다.",
"Getting started": "시작하기", "Getting started": "시작하기",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "체험 기간", "Trial duration": "체험 기간",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "Sao chép URL trang bảng giá", "Copy pricing page URL": "Sao chép URL trang bảng giá",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "Miễn phí", "Free": "Miễn phí",
"Failed to get plans": "Falha ao obter planos",
"Getting started": "Bắt đầu", "Getting started": "Bắt đầu",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "Thời gian thử nghiệm", "Trial duration": "Thời gian thử nghiệm",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "Скопировать URL прайс-листа", "Copy pricing page URL": "Скопировать URL прайс-листа",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "Бесплатно", "Free": "Бесплатно",
"Failed to get plans": "Не удалось получить планы",
"Getting started": "Выьрать план", "Getting started": "Выьрать план",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "Продолжительность пробного периода", "Trial duration": "Продолжительность пробного периода",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "Sao chép URL trang bảng giá", "Copy pricing page URL": "Sao chép URL trang bảng giá",
"Edit Pricing": "Edit Pricing", "Edit Pricing": "Edit Pricing",
"Free": "Miễn phí", "Free": "Miễn phí",
"Failed to get plans": "Không thể lấy được các kế hoạch",
"Getting started": "Bắt đầu", "Getting started": "Bắt đầu",
"New Pricing": "New Pricing", "New Pricing": "New Pricing",
"Trial duration": "Thời gian thử nghiệm", "Trial duration": "Thời gian thử nghiệm",

View File

@ -569,6 +569,7 @@
"Copy pricing page URL": "复制定价页面链接", "Copy pricing page URL": "复制定价页面链接",
"Edit Pricing": "编辑定价", "Edit Pricing": "编辑定价",
"Free": "免费", "Free": "免费",
"Failed to get plans": "未能获取计划",
"Getting started": "开始使用", "Getting started": "开始使用",
"New Pricing": "添加定价", "New Pricing": "添加定价",
"Trial duration": "试用期时长", "Trial duration": "试用期时长",

View File

@ -64,6 +64,11 @@ class PricingPage extends React.Component {
Promise.all(plans) Promise.all(plans)
.then(results => { .then(results => {
const hasError = results.some(result => result.status === "error");
if (hasError) {
Setting.showMessage("error", `${i18next.t("Failed to get plans")}`);
return;
}
this.setState({ this.setState({
plans: results, plans: results,
loading: false, loading: false,
@ -81,6 +86,11 @@ class PricingPage extends React.Component {
PricingBackend.getPricing(this.state.owner, pricingName) PricingBackend.getPricing(this.state.owner, pricingName)
.then((result) => { .then((result) => {
if (result.status === "error") {
Setting.showMessage("error", result.msg);
return;
}
this.setState({ this.setState({
loading: false, loading: false,
pricing: result, pricing: result,