-
-
Notifications
You must be signed in to change notification settings - Fork 931
/
flow_method.go
101 lines (77 loc) · 2.73 KB
/
flow_method.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package registration
import (
"database/sql/driver"
"encoding/json"
"time"
"github.com/ory/x/sqlxx"
"github.com/gofrs/uuid"
"github.com/ory/kratos/identity"
"github.com/ory/kratos/selfservice/form"
)
// swagger:model registrationFlowMethod
type FlowMethod struct {
// Method contains the flow method's credentials type.
Method identity.CredentialsType `json:"method" faker:"string" db:"method"`
// Config is the credential type's config.
Config *FlowMethodConfig `json:"config" db:"config"`
// ID is a helper struct field for gobuffalo.pop.
ID uuid.UUID `json:"-" faker:"-" db:"id"`
// FlowID is a helper struct field for gobuffalo.pop.
FlowID uuid.UUID `json:"-" faker:"-" db:"selfservice_registration_flow_id"`
// Flow is a helper struct field for gobuffalo.pop.
Flow *Flow `json:"-" faker:"-" belongs_to:"selfservice_registration_flow" fk_id:"FlowID"`
// CreatedAt is a helper struct field for gobuffalo.pop.
CreatedAt time.Time `json:"-" faker:"-" db:"created_at"`
// UpdatedAt is a helper struct field for gobuffalo.pop.
UpdatedAt time.Time `json:"-" faker:"-" db:"updated_at"`
}
func (u FlowMethod) TableName() string {
return "selfservice_registration_flow_methods"
}
type FlowMethodsRaw []FlowMethod // workaround for https://github.com/gobuffalo/pop/pull/478
type FlowMethods map[identity.CredentialsType]*FlowMethod
func (u FlowMethods) TableName() string {
// This must be stay a value receiver, using a pointer receiver will cause issues with pop.
return "selfservice_registration_flow_methods"
}
func (u FlowMethodsRaw) TableName() string {
// This must be stay a value receiver, using a pointer receiver will cause issues with pop.
return "selfservice_registration_flow_methods"
}
// swagger:ignore
type FlowMethodConfigurator interface {
form.ErrorParser
form.FieldSetter
form.FieldUnsetter
form.ValueSetter
form.Resetter
form.MessageResetter
form.CSRFSetter
form.FieldSorter
form.MessageAdder
}
// swagger:model registrationFlowMethodConfig
type FlowMethodConfig struct {
// swagger:ignore
FlowMethodConfigurator
flowMethodConfigMock
}
// swagger:model registrationFlowMethodConfigPayload
type flowMethodConfigMock struct {
*form.HTMLForm
// Providers is set for the "oidc" registration method.
Providers []form.Field `json:"providers" faker:"len=3"`
}
func (c *FlowMethodConfig) Scan(value interface{}) error {
return sqlxx.JSONScan(c, value)
}
func (c *FlowMethodConfig) Value() (driver.Value, error) {
return sqlxx.JSONValue(c)
}
func (c *FlowMethodConfig) UnmarshalJSON(data []byte) error {
c.FlowMethodConfigurator = form.NewHTMLForm("")
return json.Unmarshal(data, c.FlowMethodConfigurator)
}
func (c *FlowMethodConfig) MarshalJSON() ([]byte, error) {
return json.Marshal(c.FlowMethodConfigurator)
}