Documentation
¶
Overview ¶
Package hook defines the typed lifecycle hooks of Auth-All.
Hook semantics:
- A Before hook runs inside the database transaction of the operation. It can reject the operation by returning an error.
- An After hook runs after the transaction commits. It cannot reject the operation. An error from an After hook is reported to the logger.
Auth-All never keeps a database transaction open while it calls an external system, so arbitrary side effects belong in an After hook.
Index ¶
- type AccountLink
- type AfterAccountLinkFunc
- type AfterPasswordChangeFunc
- type AfterSessionCreateFunc
- type AfterSignInFunc
- type AfterSignOutFunc
- type AfterUserCreateFunc
- type BeforeSessionCreateFunc
- type BeforeUserCreateFunc
- type Hooks
- func (h *Hooks) OnAfterAccountLink(fn AfterAccountLinkFunc)
- func (h *Hooks) OnAfterPasswordChange(fn AfterPasswordChangeFunc)
- func (h *Hooks) OnAfterSessionCreate(fn AfterSessionCreateFunc)
- func (h *Hooks) OnAfterSignIn(fn AfterSignInFunc)
- func (h *Hooks) OnAfterSignOut(fn AfterSignOutFunc)
- func (h *Hooks) OnAfterUserCreate(fn AfterUserCreateFunc)
- func (h *Hooks) OnBeforeSessionCreate(fn BeforeSessionCreateFunc)
- func (h *Hooks) OnBeforeUserCreate(fn BeforeUserCreateFunc)
- func (h *Hooks) RunAfterAccountLink(ctx context.Context, ev *AccountLink)
- func (h *Hooks) RunAfterPasswordChange(ctx context.Context, ev *PasswordChange)
- func (h *Hooks) RunAfterSessionCreate(ctx context.Context, ev *SessionCreate)
- func (h *Hooks) RunAfterSignIn(ctx context.Context, ev *SignIn)
- func (h *Hooks) RunAfterSignOut(ctx context.Context, ev *SignOut)
- func (h *Hooks) RunAfterUserCreate(ctx context.Context, ev *UserCreate)
- func (h *Hooks) RunBeforeSessionCreate(ctx context.Context, ev *SessionCreate) error
- func (h *Hooks) RunBeforeUserCreate(ctx context.Context, ev *UserCreate) error
- type PasswordChange
- type SessionCreate
- type SignIn
- type SignOut
- type UserCreate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountLink ¶
AccountLink carries a completed external account link.
type AfterAccountLinkFunc ¶
type AfterAccountLinkFunc func(ctx context.Context, ev *AccountLink) error
AfterAccountLinkFunc runs after commit.
type AfterPasswordChangeFunc ¶
type AfterPasswordChangeFunc func(ctx context.Context, ev *PasswordChange) error
AfterPasswordChangeFunc runs after commit.
type AfterSessionCreateFunc ¶
type AfterSessionCreateFunc func(ctx context.Context, ev *SessionCreate) error
AfterSessionCreateFunc runs after commit.
type AfterSignInFunc ¶
AfterSignInFunc runs after commit.
type AfterSignOutFunc ¶
AfterSignOutFunc runs after commit.
type AfterUserCreateFunc ¶
type AfterUserCreateFunc func(ctx context.Context, ev *UserCreate) error
AfterUserCreateFunc runs after commit.
type BeforeSessionCreateFunc ¶
type BeforeSessionCreateFunc func(ctx context.Context, ev *SessionCreate) error
BeforeSessionCreateFunc runs in the transaction and can reject.
type BeforeUserCreateFunc ¶
type BeforeUserCreateFunc func(ctx context.Context, ev *UserCreate) error
BeforeUserCreateFunc runs in the transaction and can reject.
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks holds every registered lifecycle hook.
func (*Hooks) OnAfterAccountLink ¶
func (h *Hooks) OnAfterAccountLink(fn AfterAccountLinkFunc)
OnAfterAccountLink registers a hook that runs after commit.
func (*Hooks) OnAfterPasswordChange ¶
func (h *Hooks) OnAfterPasswordChange(fn AfterPasswordChangeFunc)
OnAfterPasswordChange registers a hook that runs after commit.
func (*Hooks) OnAfterSessionCreate ¶
func (h *Hooks) OnAfterSessionCreate(fn AfterSessionCreateFunc)
OnAfterSessionCreate registers a hook that runs after commit.
func (*Hooks) OnAfterSignIn ¶
func (h *Hooks) OnAfterSignIn(fn AfterSignInFunc)
OnAfterSignIn registers a hook that runs after commit.
func (*Hooks) OnAfterSignOut ¶
func (h *Hooks) OnAfterSignOut(fn AfterSignOutFunc)
OnAfterSignOut registers a hook that runs after commit.
func (*Hooks) OnAfterUserCreate ¶
func (h *Hooks) OnAfterUserCreate(fn AfterUserCreateFunc)
OnAfterUserCreate registers a hook that runs after commit.
func (*Hooks) OnBeforeSessionCreate ¶
func (h *Hooks) OnBeforeSessionCreate(fn BeforeSessionCreateFunc)
OnBeforeSessionCreate registers a hook that runs in the transaction and can reject.
func (*Hooks) OnBeforeUserCreate ¶
func (h *Hooks) OnBeforeUserCreate(fn BeforeUserCreateFunc)
OnBeforeUserCreate registers a hook that runs in the transaction and can reject.
func (*Hooks) RunAfterAccountLink ¶
func (h *Hooks) RunAfterAccountLink(ctx context.Context, ev *AccountLink)
RunAfterAccountLink runs the registered hooks after commit.
func (*Hooks) RunAfterPasswordChange ¶
func (h *Hooks) RunAfterPasswordChange(ctx context.Context, ev *PasswordChange)
RunAfterPasswordChange runs the registered hooks after commit.
func (*Hooks) RunAfterSessionCreate ¶
func (h *Hooks) RunAfterSessionCreate(ctx context.Context, ev *SessionCreate)
RunAfterSessionCreate runs the registered hooks after commit.
func (*Hooks) RunAfterSignIn ¶
RunAfterSignIn runs the registered hooks after commit.
func (*Hooks) RunAfterSignOut ¶
RunAfterSignOut runs the registered hooks after commit.
func (*Hooks) RunAfterUserCreate ¶
func (h *Hooks) RunAfterUserCreate(ctx context.Context, ev *UserCreate)
RunAfterUserCreate runs the registered hooks after commit.
func (*Hooks) RunBeforeSessionCreate ¶
func (h *Hooks) RunBeforeSessionCreate(ctx context.Context, ev *SessionCreate) error
RunBeforeSessionCreate runs the registered hooks and stops at the first error.
func (*Hooks) RunBeforeUserCreate ¶
func (h *Hooks) RunBeforeUserCreate(ctx context.Context, ev *UserCreate) error
RunBeforeUserCreate runs the registered hooks and stops at the first error.
type PasswordChange ¶
PasswordChange carries a completed password change.
type SessionCreate ¶
SessionCreate carries a session creation.
type SignIn ¶
SignIn carries a completed sign-in. Method names the authentication method, for example "email", "magic-link", or a provider id.