support unlinking external authentication

This commit is contained in:
MaysWind
2025-10-25 02:45:40 +08:00
parent 7b49a9f142
commit ce752c992c
26 changed files with 707 additions and 39 deletions
+11 -4
View File
@@ -1,5 +1,7 @@
package core
const USER_EXTERNAL_AUTH_TYPE_CATEOGRY_OAUTH2 = "oauth2"
// UserExternalAuthType represents the type of user external authentication
type UserExternalAuthType string
@@ -11,14 +13,19 @@ const (
USER_EXTERNAL_AUTH_TYPE_OAUTH2_GITHUB UserExternalAuthType = "github"
)
// IsValid checks if the UserExternalAuthType is valid
func (t UserExternalAuthType) IsValid() bool {
// GetCategory returns the category of the UserExternalAuthType
func (t UserExternalAuthType) GetCategory() string {
switch t {
case USER_EXTERNAL_AUTH_TYPE_OAUTH2_OIDC,
USER_EXTERNAL_AUTH_TYPE_OAUTH2_NEXTCLOUD,
USER_EXTERNAL_AUTH_TYPE_OAUTH2_GITEA,
USER_EXTERNAL_AUTH_TYPE_OAUTH2_GITHUB:
return true
return USER_EXTERNAL_AUTH_TYPE_CATEOGRY_OAUTH2
}
return false
return ""
}
// IsValid checks if the UserExternalAuthType is valid
func (t UserExternalAuthType) IsValid() bool {
return t.GetCategory() != ""
}