package migration

import "strings"

const AuthModeOAuth = "oauth"
const AuthModeGoogleDWD = "google_dwd"
const AuthModeMicrosoftApp = "microsoft_app"

func NormalizeAuthMode(provider, authMode string) string {
	authMode = strings.ToLower(strings.TrimSpace(authMode))
	if authMode == "" {
		return AuthModeOAuth
	}
	provider = strings.ToLower(strings.TrimSpace(provider))
	switch authMode {
	case AuthModeGoogleDWD:
		if provider == "google" {
			return AuthModeGoogleDWD
		}
	case AuthModeMicrosoftApp:
		if provider == "microsoft" {
			return AuthModeMicrosoftApp
		}
	}
	return AuthModeOAuth
}

func UsesUserOAuth(provider, authMode string) bool {
	authMode = NormalizeAuthMode(provider, authMode)
	switch authMode {
	case AuthModeGoogleDWD, AuthModeMicrosoftApp:
		return false
	default:
		return true
	}
}
