mirror of https://gitee.com/answerdev/answer.git
feat(usercenter): plugin user center add i18n
This commit is contained in:
parent
3c96abfcc5
commit
af08b3e392
|
@ -51,7 +51,7 @@ backend:
|
||||||
privilege:
|
privilege:
|
||||||
level_1:
|
level_1:
|
||||||
description:
|
description:
|
||||||
other: Level 1 (less reputation required for startup community)
|
other: Level 1 (less reputation required for private team, group)
|
||||||
level_2:
|
level_2:
|
||||||
description:
|
description:
|
||||||
other: Level 2 (low reputation required for startup community)
|
other: Level 2 (low reputation required for startup community)
|
||||||
|
@ -140,7 +140,7 @@ backend:
|
||||||
verify_url_expired:
|
verify_url_expired:
|
||||||
other: Email verified URL has expired, please resend the email.
|
other: Email verified URL has expired, please resend the email.
|
||||||
illegal_email_domain_error:
|
illegal_email_domain_error:
|
||||||
other: The domain name of the current email address cannot be registered.
|
other: Email is not allowed from that email domain. Please use another one.
|
||||||
lang:
|
lang:
|
||||||
not_found:
|
not_found:
|
||||||
other: Language file not found.
|
other: Language file not found.
|
||||||
|
@ -232,6 +232,10 @@ backend:
|
||||||
other: You cannot modify your role.
|
other: You cannot modify your role.
|
||||||
not_allowed_registration:
|
not_allowed_registration:
|
||||||
other: Currently the site is not open for registration
|
other: Currently the site is not open for registration
|
||||||
|
access_denied:
|
||||||
|
other: Access denied
|
||||||
|
page_access_denied:
|
||||||
|
other: You do not have access to this page.
|
||||||
config:
|
config:
|
||||||
read_config_failed:
|
read_config_failed:
|
||||||
other: Read config failed
|
other: Read config failed
|
||||||
|
|
|
@ -136,6 +136,8 @@ backend:
|
||||||
other: 邮箱需要验证。
|
other: 邮箱需要验证。
|
||||||
verify_url_expired:
|
verify_url_expired:
|
||||||
other: 邮箱验证的网址已过期,请重新发送邮件。
|
other: 邮箱验证的网址已过期,请重新发送邮件。
|
||||||
|
illegal_email_domain_error:
|
||||||
|
other: 该域名的邮箱无法使用。请尝试更换其他邮箱。
|
||||||
lang:
|
lang:
|
||||||
not_found:
|
not_found:
|
||||||
other: 语言未找到
|
other: 语言未找到
|
||||||
|
@ -225,6 +227,10 @@ backend:
|
||||||
other: 您不能修改自己的角色。
|
other: 您不能修改自己的角色。
|
||||||
not_allowed_registration:
|
not_allowed_registration:
|
||||||
other: 目前该站点未开放注册
|
other: 目前该站点未开放注册
|
||||||
|
access_denied:
|
||||||
|
other: 访问被拒绝
|
||||||
|
page_access_denied:
|
||||||
|
other: 你没有权限进入这个页面。
|
||||||
config:
|
config:
|
||||||
read_config_failed:
|
read_config_failed:
|
||||||
other: 读取配置失败
|
other: 读取配置失败
|
||||||
|
@ -1112,6 +1118,9 @@ ui:
|
||||||
installed_plugins: 插件列表
|
installed_plugins: 插件列表
|
||||||
website_welcome: 欢迎来到 {{site_name}}
|
website_welcome: 欢迎来到 {{site_name}}
|
||||||
plugins:
|
plugins:
|
||||||
|
login: 登录
|
||||||
|
qrcode_login_tip: 请使用 {{ agentName }} 扫描二维码登录
|
||||||
|
login_failed_email_tip: 登录失败, 请允许该应用程序访问您的电子邮件信息,然后再试一次。
|
||||||
oauth:
|
oauth:
|
||||||
connect: 连接到 {{ auth_name }}
|
connect: 连接到 {{ auth_name }}
|
||||||
remove: 解绑 {{ auth_name }}
|
remove: 解绑 {{ auth_name }}
|
||||||
|
|
|
@ -74,4 +74,6 @@ const (
|
||||||
AdminCannotUpdateTheirPassword = "error.admin.cannot_update_their_password"
|
AdminCannotUpdateTheirPassword = "error.admin.cannot_update_their_password"
|
||||||
AdminCannotModifySelfStatus = "error.admin.cannot_modify_self_status"
|
AdminCannotModifySelfStatus = "error.admin.cannot_modify_self_status"
|
||||||
UserExternalLoginUnbindingForbidden = "error.user.external_login_unbinding_forbidden"
|
UserExternalLoginUnbindingForbidden = "error.user.external_login_unbinding_forbidden"
|
||||||
|
UserAccessDenied = "error.user.access_denied"
|
||||||
|
UserPageAccessDenied = "error.user.page_access_denied"
|
||||||
)
|
)
|
||||||
|
|
|
@ -60,6 +60,7 @@ func (uc *UserCenterController) UserCenterAgent(ctx *gin.Context) {
|
||||||
_ = plugin.CallUserCenter(func(uc plugin.UserCenter) error {
|
_ = plugin.CallUserCenter(func(uc plugin.UserCenter) error {
|
||||||
info := uc.Description()
|
info := uc.Description()
|
||||||
resp.AgentInfo.Name = info.Name
|
resp.AgentInfo.Name = info.Name
|
||||||
|
resp.AgentInfo.DisplayName = info.DisplayName.Translate(ctx)
|
||||||
resp.AgentInfo.Icon = info.Icon
|
resp.AgentInfo.Icon = info.Icon
|
||||||
resp.AgentInfo.Url = info.Url
|
resp.AgentInfo.Url = info.Url
|
||||||
resp.AgentInfo.ControlCenterItems = make([]*schema.ControlCenter, 0)
|
resp.AgentInfo.ControlCenterItems = make([]*schema.ControlCenter, 0)
|
||||||
|
@ -138,7 +139,7 @@ func (uc *UserCenterController) UserCenterLoginCallback(ctx *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(resp.ErrMsg) > 0 {
|
if len(resp.ErrMsg) > 0 {
|
||||||
ctx.Redirect(http.StatusFound, "/50x?msg="+resp.ErrMsg)
|
ctx.Redirect(http.StatusFound, fmt.Sprintf("/50x?title=%s&msg=%s", resp.ErrTitle, resp.ErrMsg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
userCenter.AfterLogin(userInfo.ExternalID, resp.AccessToken)
|
userCenter.AfterLogin(userInfo.ExternalID, resp.AccessToken)
|
||||||
|
@ -173,7 +174,7 @@ func (uc *UserCenterController) UserCenterSignUpCallback(ctx *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(resp.ErrMsg) > 0 {
|
if len(resp.ErrMsg) > 0 {
|
||||||
ctx.Redirect(http.StatusFound, "/50x?msg="+resp.ErrMsg)
|
ctx.Redirect(http.StatusFound, fmt.Sprintf("/50x?title=%s&msg=%s", resp.ErrTitle, resp.ErrMsg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
userCenter.AfterLogin(userInfo.ExternalID, resp.AccessToken)
|
userCenter.AfterLogin(userInfo.ExternalID, resp.AccessToken)
|
||||||
|
|
|
@ -56,6 +56,7 @@ func (g *GetPluginConfigResp) SetConfigFields(ctx *gin.Context, fields []plugin.
|
||||||
UIOptions: ConfigFieldUIOptions{
|
UIOptions: ConfigFieldUIOptions{
|
||||||
Rows: field.UIOptions.Rows,
|
Rows: field.UIOptions.Rows,
|
||||||
InputType: string(field.UIOptions.InputType),
|
InputType: string(field.UIOptions.InputType),
|
||||||
|
Variant: field.UIOptions.Variant,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
configField.UIOptions.Placeholder = field.UIOptions.Placeholder.Translate(ctx)
|
configField.UIOptions.Placeholder = field.UIOptions.Placeholder.Translate(ctx)
|
||||||
|
@ -94,6 +95,7 @@ type ConfigFieldUIOptions struct {
|
||||||
InputType string `json:"input_type,omitempty"`
|
InputType string `json:"input_type,omitempty"`
|
||||||
Label string `json:"label,omitempty"`
|
Label string `json:"label,omitempty"`
|
||||||
Action *ConfigFieldUIOptionAction `json:"action,omitempty"`
|
Action *ConfigFieldUIOptionAction `json:"action,omitempty"`
|
||||||
|
Variant string `json:"variant,omitempty"`
|
||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ type UserCenterAgentResp struct {
|
||||||
|
|
||||||
type AgentInfo struct {
|
type AgentInfo struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
DisplayName string `json:"display_name"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon"`
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
LoginRedirectURL string `json:"login_redirect_url"`
|
LoginRedirectURL string `json:"login_redirect_url"`
|
||||||
|
|
|
@ -5,7 +5,8 @@ type UserExternalLoginResp struct {
|
||||||
BindingKey string `json:"binding_key"`
|
BindingKey string `json:"binding_key"`
|
||||||
AccessToken string `json:"access_token"`
|
AccessToken string `json:"access_token"`
|
||||||
// ErrMsg error message, if not empty, means login failed and this message should be displayed.
|
// ErrMsg error message, if not empty, means login failed and this message should be displayed.
|
||||||
ErrMsg string `json:"-"`
|
ErrMsg string `json:"-"`
|
||||||
|
ErrTitle string `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExternalLoginBindingUserSendEmailReq external login binding user request
|
// ExternalLoginBindingUserSendEmailReq external login binding user request
|
||||||
|
|
|
@ -59,7 +59,9 @@ func (us *UserCenterLoginService) ExternalLogin(
|
||||||
if !checker.EmailInAllowEmailDomain(basicUserInfo.Email, siteInfo.AllowEmailDomains) {
|
if !checker.EmailInAllowEmailDomain(basicUserInfo.Email, siteInfo.AllowEmailDomains) {
|
||||||
log.Debugf("email domain not allowed: %s", basicUserInfo.Email)
|
log.Debugf("email domain not allowed: %s", basicUserInfo.Email)
|
||||||
return &schema.UserExternalLoginResp{
|
return &schema.UserExternalLoginResp{
|
||||||
ErrMsg: translator.Tr(handler.GetLangByCtx(ctx), reason.EmailIllegalDomainError)}, nil
|
ErrTitle: translator.Tr(handler.GetLangByCtx(ctx), reason.UserAccessDenied),
|
||||||
|
ErrMsg: translator.Tr(handler.GetLangByCtx(ctx), reason.EmailIllegalDomainError),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +77,13 @@ func (us *UserCenterLoginService) ExternalLogin(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if exist {
|
if exist {
|
||||||
|
// if user is deleted, do not allow login
|
||||||
|
if oldUserInfo.Status == entity.UserStatusDeleted {
|
||||||
|
return &schema.UserExternalLoginResp{
|
||||||
|
ErrTitle: translator.Tr(handler.GetLangByCtx(ctx), reason.UserAccessDenied),
|
||||||
|
ErrMsg: translator.Tr(handler.GetLangByCtx(ctx), reason.UserPageAccessDenied),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
if err := us.userRepo.UpdateLastLoginDate(ctx, oldUserInfo.ID); err != nil {
|
if err := us.userRepo.UpdateLastLoginDate(ctx, oldUserInfo.ID); err != nil {
|
||||||
log.Errorf("update user last login date failed: %v", err)
|
log.Errorf("update user last login date failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ type ConfigFieldUIOptions struct {
|
||||||
InputType InputType `json:"input_type,omitempty"`
|
InputType InputType `json:"input_type,omitempty"`
|
||||||
Label Translator `json:"label,omitempty"`
|
Label Translator `json:"label,omitempty"`
|
||||||
Action *ConfigFieldUIOptionAction `json:"action,omitempty"`
|
Action *ConfigFieldUIOptionAction `json:"action,omitempty"`
|
||||||
|
Variant string `json:"variant,omitempty"`
|
||||||
Text Translator `json:"text,omitempty"`
|
Text Translator `json:"text,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,16 @@ type UserCenter interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserCenterDesc struct {
|
type UserCenterDesc struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Icon string `json:"icon"`
|
DisplayName Translator `json:"display_name"`
|
||||||
Url string `json:"url"`
|
Icon string `json:"icon"`
|
||||||
LoginRedirectURL string `json:"login_redirect_url"`
|
Url string `json:"url"`
|
||||||
SignUpRedirectURL string `json:"sign_up_redirect_url"`
|
LoginRedirectURL string `json:"login_redirect_url"`
|
||||||
RankAgentEnabled bool `json:"rank_agent_enabled"`
|
SignUpRedirectURL string `json:"sign_up_redirect_url"`
|
||||||
UserStatusAgentEnabled bool `json:"user_status_agent_enabled"`
|
RankAgentEnabled bool `json:"rank_agent_enabled"`
|
||||||
MustAuthEmailEnabled bool `json:"must_auth_email_enabled"`
|
UserStatusAgentEnabled bool `json:"user_status_agent_enabled"`
|
||||||
EnabledOriginalUserSystem bool `json:"enabled_original_user_system"`
|
MustAuthEmailEnabled bool `json:"must_auth_email_enabled"`
|
||||||
|
EnabledOriginalUserSystem bool `json:"enabled_original_user_system"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserStatus int
|
type UserStatus int
|
||||||
|
|
Loading…
Reference in New Issue