package models

import "database/sql/driver"

// Authentication methods available
type AuthenticationMethodType string

const (
	AuthMethodPassword   AuthenticationMethodType = "password"    // Password based authentication
	AuthMethodGAuth      AuthenticationMethodType = "g-auth"      // Totp based 2nd factor
	AuthMethodMail       AuthenticationMethodType = "mail"        // Mail based 2nd factor. Unused
	AuthMethodPasskey2fa AuthenticationMethodType = "passkey-2fa" // Passkey based 2nd factor. Unused
	AuthMethodPasskey    AuthenticationMethodType = "passkey"     // Passkey as only auth key
)

// A list of all known authentication methods.
// Known != supported
var AllAuthMethods = []AuthenticationMethodType{
	AuthMethodPassword, AuthMethodGAuth, AuthMethodMail, AuthMethodPasskey, AuthMethodPasskey2fa,
}

func (ct *AuthenticationMethodType) Scan(value any) error {
	*ct = AuthenticationMethodType(value.([]byte))
	return nil
}

func (ct AuthenticationMethodType) Value() (driver.Value, error) {
	return string(ct), nil
}
