feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
@@ -5,9 +5,11 @@ import (
|
||||
"html"
|
||||
|
||||
"github.com/QuantumNous/new-api/common"
|
||||
"github.com/QuantumNous/new-api/i18n"
|
||||
"github.com/QuantumNous/new-api/model"
|
||||
"github.com/QuantumNous/new-api/oauth"
|
||||
"github.com/QuantumNous/new-api/setting/system_setting"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func UnbindAccountOAuth(identity AuthIdentity, providerID int) error {
|
||||
@@ -29,13 +31,27 @@ func UnbindAccountOAuth(identity AuthIdentity, providerID int) error {
|
||||
return model.UnbindUserOAuthForSession(identity, providerID, enabled)
|
||||
}
|
||||
|
||||
// AccountMailLanguage is the language of mail about a user's account: the
|
||||
// language the user saved, else the one the request stated.
|
||||
func AccountMailLanguage(c *gin.Context, userId int) string {
|
||||
if lang := model.GetUserLanguage(userId); lang != "" {
|
||||
return lang
|
||||
}
|
||||
return i18n.StatedLang(c)
|
||||
}
|
||||
|
||||
// NotifyAccountSecurityChange never includes credentials or tokens. The caller
|
||||
// records delivery failure independently from the already-committed change.
|
||||
func NotifyAccountSecurityChange(email, event string) error {
|
||||
// eventKey names the change; the notice is written in lang (see
|
||||
// AccountMailLanguage).
|
||||
func NotifyAccountSecurityChange(lang, email, eventKey string, eventArgs ...map[string]any) error {
|
||||
if email == "" {
|
||||
return nil
|
||||
}
|
||||
subject := common.SystemName + " — Account security notification"
|
||||
content := fmt.Sprintf("<p>Your account security settings have changed: %s.</p><p>If you did not make this change, open your account security settings, revoke other login sessions, and contact your administrator.</p>", html.EscapeString(event))
|
||||
event := html.EscapeString(i18n.Translate(lang, eventKey, eventArgs...))
|
||||
subject := i18n.Translate(lang, i18n.MsgEmailSecurityNoticeSubject, map[string]any{"SystemName": common.SystemName})
|
||||
content := fmt.Sprintf("<p>%s</p><p>%s</p>",
|
||||
i18n.Translate(lang, i18n.MsgEmailSecurityNoticeChanged, map[string]any{"Event": event}),
|
||||
i18n.Translate(lang, i18n.MsgEmailSecurityNoticeAdvice))
|
||||
return common.SendEmail(subject, email, content)
|
||||
}
|
||||
Reference in new issue
Block a user