Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 9m20s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 55m7s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
42 lines
1.5 KiB
Go
42 lines
1.5 KiB
Go
package service
|
|
|
|
import (
|
|
"fmt"
|
|
"html"
|
|
|
|
"github.com/QuantumNous/new-api/common"
|
|
"github.com/QuantumNous/new-api/model"
|
|
"github.com/QuantumNous/new-api/oauth"
|
|
"github.com/QuantumNous/new-api/setting/system_setting"
|
|
)
|
|
|
|
func UnbindAccountOAuth(identity AuthIdentity, providerID int) error {
|
|
enabled := model.AccountLoginMethods{
|
|
Password: common.PasswordLoginEnabled,
|
|
Passkey: system_setting.GetPasskeySettings().Enabled,
|
|
WeChat: common.WeChatAuthEnabled,
|
|
}
|
|
for _, provider := range oauth.GetAllProviders() {
|
|
if !provider.IsEnabled() {
|
|
continue
|
|
}
|
|
if custom, ok := provider.(*oauth.GenericOAuthProvider); ok {
|
|
enabled.CustomProviderIDs = append(enabled.CustomProviderIDs, custom.GetProviderId())
|
|
} else {
|
|
enabled.OAuthColumns = append(enabled.OAuthColumns, provider.ProviderUserIDColumn())
|
|
}
|
|
}
|
|
return model.UnbindUserOAuthForSession(identity, providerID, enabled)
|
|
}
|
|
|
|
// NotifyAccountSecurityChange never includes credentials or tokens. The caller
|
|
// records delivery failure independently from the already-committed change.
|
|
func NotifyAccountSecurityChange(email, event string) 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))
|
|
return common.SendEmail(subject, email, content)
|
|
}
|