mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 04:10:20 +08:00
feat: support i18n in backend err messages (#1232)
* feat: support i18n in backend err messages * use gofumpt to fmt code * fix review problems * support auto generate err message * delete beego/i18n moudle * fix Github action test problems * fix review problems * use gofumpt to format code * use gofumpt to fmt code
This commit is contained in:
@ -47,7 +47,7 @@ func (c *ApiController) Unlink() {
|
||||
|
||||
if user.Id != unlinkedUser.Id && !user.IsGlobalAdmin {
|
||||
// if the user is not the same as the one we are unlinking, we need to make sure the user is the global admin.
|
||||
c.ResponseError("You are not the global admin, you can't unlink other users")
|
||||
c.ResponseError(c.T("AuthErr.CanNotUnlinkUsers"))
|
||||
return
|
||||
}
|
||||
|
||||
@ -55,23 +55,23 @@ func (c *ApiController) Unlink() {
|
||||
// if the user is unlinking themselves, should check the provider can be unlinked, if not, we should return an error.
|
||||
application := object.GetApplicationByUser(user)
|
||||
if application == nil {
|
||||
c.ResponseError("You can't unlink yourself, you are not a member of any application")
|
||||
c.ResponseError(c.T("AuthErr.CanNotLinkMySelf"))
|
||||
return
|
||||
}
|
||||
|
||||
if len(application.Providers) == 0 {
|
||||
c.ResponseError("This application has no providers")
|
||||
c.ResponseError(c.T("ApplicationErr.HasNoProviders"))
|
||||
return
|
||||
}
|
||||
|
||||
provider := application.GetProviderItemByType(providerType)
|
||||
if provider == nil {
|
||||
c.ResponseError("This application has no providers of type " + providerType)
|
||||
c.ResponseError(c.T("ApplicationErr.HasNoProvidersOfType") + providerType)
|
||||
return
|
||||
}
|
||||
|
||||
if !provider.CanUnlink {
|
||||
c.ResponseError("This provider can't be unlinked")
|
||||
c.ResponseError(c.T("ProviderErr.CanNotBeUnlinked"))
|
||||
return
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ func (c *ApiController) Unlink() {
|
||||
value := object.GetUserField(&unlinkedUser, providerType)
|
||||
|
||||
if value == "" {
|
||||
c.ResponseError("Please link first", value)
|
||||
c.ResponseError(c.T("ProviderErr.LinkFirstErr"), value)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user