mirror of
https://github.com/teamhanko/hanko.git
synced 2025-10-28 06:37:57 +08:00
This pull request introduces the new Flowpilot system along with several new features and various improvements. The key enhancements include configurable authorization, registration, and profile flows, as well as the ability to enable and disable user identifiers (e.g., email addresses and usernames) and login methods. --------- Co-authored-by: Frederic Jahn <frederic.jahn@hanko.io> Co-authored-by: Lennart Fleischmann <lennart.fleischmann@hanko.io> Co-authored-by: lfleischmann <67686424+lfleischmann@users.noreply.github.com> Co-authored-by: merlindru <hello@merlindru.com>
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package models
|
|
|
|
import (
|
|
"github.com/teamhanko/hanko/backend/flowpilot"
|
|
"time"
|
|
|
|
"github.com/gobuffalo/pop/v6"
|
|
"github.com/gobuffalo/validate/v3"
|
|
"github.com/gofrs/uuid"
|
|
)
|
|
|
|
// Flow is used by pop to map your flows database table to your go code.
|
|
type Flow struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
Data string `json:"data" db:"data"`
|
|
Version int `json:"version" db:"version"`
|
|
CSRFToken string `json:"csrf_token" db:"csrf_token"`
|
|
ExpiresAt time.Time `json:"expires_at" db:"expires_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
}
|
|
|
|
func (f *Flow) ToFlowpilotModel() *flowpilot.FlowModel {
|
|
flow := flowpilot.FlowModel{
|
|
ID: f.ID,
|
|
Data: f.Data,
|
|
Version: f.Version,
|
|
CSRFToken: f.CSRFToken,
|
|
ExpiresAt: f.ExpiresAt,
|
|
CreatedAt: f.CreatedAt,
|
|
UpdatedAt: f.UpdatedAt,
|
|
}
|
|
|
|
return &flow
|
|
}
|
|
|
|
// Flows is not required by pop and may be deleted
|
|
type Flows []Flow
|
|
|
|
// Validate gets run every time you call a "pop.validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method.
|
|
// This method is not required and may be deleted.
|
|
func (f *Flow) Validate(tx *pop.Connection) (*validate.Errors, error) {
|
|
return validate.NewErrors(), nil
|
|
}
|
|
|
|
// ValidateCreate gets run every time you call "pop.ValidateAndCreate" method.
|
|
// This method is not required and may be deleted.
|
|
func (f *Flow) ValidateCreate(tx *pop.Connection) (*validate.Errors, error) {
|
|
return validate.NewErrors(), nil
|
|
}
|
|
|
|
// ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method.
|
|
// This method is not required and may be deleted.
|
|
func (f *Flow) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error) {
|
|
return validate.NewErrors(), nil
|
|
}
|