Uniformize enum style

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-05-20 09:41:22 -07:00
parent bc6d028ef3
commit 30db98455d
191 changed files with 7946 additions and 5129 deletions

View File

@@ -16,6 +16,7 @@ package coredata
import (
"context"
"encoding"
"errors"
"fmt"
"maps"
@@ -60,6 +61,53 @@ const (
AuthMethodOIDC AuthMethod = "OIDC"
)
var (
_ fmt.Stringer = AuthMethod("")
_ encoding.TextMarshaler = AuthMethod("")
_ encoding.TextUnmarshaler = (*AuthMethod)(nil)
)
func AuthMethods() []AuthMethod {
return []AuthMethod{
AuthMethodMagicLink,
AuthMethodPassword,
AuthMethodSAML,
AuthMethodOIDC,
}
}
func (v AuthMethod) IsValid() bool {
switch v {
case
AuthMethodMagicLink,
AuthMethodPassword,
AuthMethodSAML,
AuthMethodOIDC:
return true
}
return false
}
func (v AuthMethod) String() string {
return string(v)
}
func (v AuthMethod) MarshalText() ([]byte, error) {
return []byte(v.String()), nil
}
func (v *AuthMethod) UnmarshalText(text []byte) error {
val := AuthMethod(text)
if !val.IsValid() {
return fmt.Errorf("invalid AuthMethod value: %q", string(text))
}
*v = val
return nil
}
func NewRootSession(identityID gid.GID, method AuthMethod, duration time.Duration) *Session {
now := time.Now()