database

package
v0.0.0-...-2389199 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientInfoDbOutput

type ClientInfoDbOutput struct {
	Sub, Name, Secret, Domain, Owner string
	Public, SSO, Active              bool
}

func (*ClientInfoDbOutput) GetDomain

func (c *ClientInfoDbOutput) GetDomain() string

func (*ClientInfoDbOutput) GetID

func (c *ClientInfoDbOutput) GetID() string

func (*ClientInfoDbOutput) GetName

func (c *ClientInfoDbOutput) GetName() string

GetName is an extra field for the oauth handler to display the application name

func (*ClientInfoDbOutput) GetSecret

func (c *ClientInfoDbOutput) GetSecret() string

func (*ClientInfoDbOutput) GetUserID

func (c *ClientInfoDbOutput) GetUserID() string

func (*ClientInfoDbOutput) IsActive

func (c *ClientInfoDbOutput) IsActive() bool

IsActive is an extra field for the app manager to get the active state

func (*ClientInfoDbOutput) IsPublic

func (c *ClientInfoDbOutput) IsPublic() bool

func (*ClientInfoDbOutput) IsSSO

func (c *ClientInfoDbOutput) IsSSO() bool

IsSSO is an extra field for the oauth handler to skip the user input stage this is for trusted applications to get permissions without asking the user

type DB

type DB struct {
	// contains filtered or unexported fields
}

func Open

func Open(p string) (*DB, error)

func (*DB) Begin

func (d *DB) Begin() (*Tx, error)

func (*DB) BeginCtx

func (d *DB) BeginCtx(ctx context.Context) (*Tx, error)

func (*DB) Close

func (d *DB) Close() error

type LocaleScanner

type LocaleScanner struct{ language.Tag }

func (LocaleScanner) MarshalJSON

func (l LocaleScanner) MarshalJSON() ([]byte, error)

func (*LocaleScanner) Scan

func (l *LocaleScanner) Scan(src any) error

func (*LocaleScanner) UnmarshalJSON

func (l *LocaleScanner) UnmarshalJSON(bytes []byte) error

type LocationScanner

type LocationScanner struct{ *time.Location }

func (LocationScanner) MarshalJSON

func (l LocationScanner) MarshalJSON() ([]byte, error)

func (*LocationScanner) Scan

func (l *LocationScanner) Scan(src any) error

func (*LocationScanner) UnmarshalJSON

func (l *LocationScanner) UnmarshalJSON(bytes []byte) error

type NullDateScanner

type NullDateScanner struct{ sql.NullTime }

func (NullDateScanner) MarshalJSON

func (t NullDateScanner) MarshalJSON() ([]byte, error)

func (*NullDateScanner) Null

func (t *NullDateScanner) Null() bool

func (*NullDateScanner) Scan

func (t *NullDateScanner) Scan(src any) error

func (NullDateScanner) String

func (t NullDateScanner) String() string

func (*NullDateScanner) UnmarshalJSON

func (t *NullDateScanner) UnmarshalJSON(bytes []byte) error

type NullStringScanner

type NullStringScanner struct{ sql.NullString }

func (NullStringScanner) MarshalJSON

func (s NullStringScanner) MarshalJSON() ([]byte, error)

func (*NullStringScanner) Null

func (s *NullStringScanner) Null() bool

func (*NullStringScanner) Scan

func (s *NullStringScanner) Scan(src any) error

func (NullStringScanner) String

func (s NullStringScanner) String() string

func (*NullStringScanner) UnmarshalJSON

func (s *NullStringScanner) UnmarshalJSON(bytes []byte) error

type PronounScanner

type PronounScanner struct{ pronouns.Pronoun }

func (PronounScanner) MarshalJSON

func (p PronounScanner) MarshalJSON() ([]byte, error)

func (*PronounScanner) Scan

func (p *PronounScanner) Scan(src any) error

func (*PronounScanner) UnmarshalJSON

func (p *PronounScanner) UnmarshalJSON(bytes []byte) error

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) ChangeUserPassword

func (t *Tx) ChangeUserPassword(sub, pwOld, pwNew string) error

func (*Tx) CheckLogin

func (t *Tx) CheckLogin(un, pw string) (*User, bool, bool, error)

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) GetAppList

func (t *Tx) GetAppList(owner string, admin bool, offset int) ([]ClientInfoDbOutput, error)

func (*Tx) GetClientInfo

func (t *Tx) GetClientInfo(sub string) (oauth2.ClientInfo, error)

func (*Tx) GetTwoFactor

func (t *Tx) GetTwoFactor(sub string) (string, int, error)

func (*Tx) GetUser

func (t *Tx) GetUser(sub string) (*User, error)

func (*Tx) GetUserDisplayName

func (t *Tx) GetUserDisplayName(sub string) (*User, error)

func (*Tx) GetUserEmail

func (t *Tx) GetUserEmail(sub string) (string, error)

func (*Tx) GetUserList

func (t *Tx) GetUserList(offset int) ([]User, error)

func (*Tx) GetUserRole

func (t *Tx) GetUserRole(sub string) (UserRole, error)

func (*Tx) HasTwoFactor

func (t *Tx) HasTwoFactor(sub string) (bool, error)

func (*Tx) HasUser

func (t *Tx) HasUser() error

func (*Tx) InsertClientApp

func (t *Tx) InsertClientApp(name, domain string, public, sso, active bool, owner string) error

func (*Tx) InsertUser

func (t *Tx) InsertUser(name, un, pw, email string, verifyEmail bool, role UserRole, active bool) (uuid.UUID, error)

func (*Tx) ModifyUser

func (t *Tx) ModifyUser(sub string, v *UserPatch) error

func (*Tx) ResetClientAppSecret

func (t *Tx) ResetClientAppSecret(subject, owner string) (string, error)

func (*Tx) Rollback

func (t *Tx) Rollback()

func (*Tx) SetTwoFactor

func (t *Tx) SetTwoFactor(sub string, secret string, digits int) error

func (*Tx) UpdateClientApp

func (t *Tx) UpdateClientApp(subject, owner string, name, domain string, public, sso, active bool) error

func (*Tx) UpdateUser

func (t *Tx) UpdateUser(subject string, role UserRole, active bool) error

func (*Tx) UserEmailExists

func (t *Tx) UserEmailExists(email string) (exists bool, err error)

func (*Tx) UserResetPassword

func (t *Tx) UserResetPassword(sub string, pw string) error

func (*Tx) VerifyUserEmail

func (t *Tx) VerifyUserEmail(sub string) error

type User

type User struct {
	Sub           string            `json:"sub"`
	Name          string            `json:"name,omitempty"`
	Username      string            `json:"username"`
	Picture       NullStringScanner `json:"picture,omitempty"`
	Website       NullStringScanner `json:"website,omitempty"`
	Email         string            `json:"email"`
	EmailVerified bool              `json:"email_verified"`
	Pronouns      PronounScanner    `json:"pronouns,omitempty"`
	Birthdate     NullDateScanner   `json:"birthdate,omitempty"`
	ZoneInfo      LocationScanner   `json:"zoneinfo,omitempty"`
	Locale        LocaleScanner     `json:"locale,omitempty"`
	Role          UserRole          `json:"role"`
	UpdatedAt     time.Time         `json:"updated_at"`
	Active        bool              `json:"active"`
}

type UserPatch

type UserPatch struct {
	Name      string
	Picture   string
	Website   string
	Pronouns  pronouns.Pronoun
	Birthdate sql.NullTime
	ZoneInfo  *time.Location
	Locale    language.Tag
}

func (*UserPatch) ParseFromForm

func (u *UserPatch) ParseFromForm(v url.Values) (safeErrs []error)

type UserRole

type UserRole int
const (
	RoleMember UserRole = iota
	RoleAdmin
	RoleToDelete
)

func (UserRole) IsValid

func (r UserRole) IsValid() bool

func (UserRole) String

func (r UserRole) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL