-
Notifications
You must be signed in to change notification settings - Fork 28
/
ensure_password_change.go
45 lines (37 loc) · 1.23 KB
/
ensure_password_change.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
package nodes
import (
"github.com/authgear/authgear-server/pkg/api/model"
"github.com/authgear/authgear-server/pkg/lib/authn"
"github.com/authgear/authgear-server/pkg/lib/interaction"
)
func init() {
interaction.RegisterNode(&NodeEnsurePasswordChange{})
}
type EdgeEnsurePasswordChange struct {
Stage authn.AuthenticationStage
}
func (e *EdgeEnsurePasswordChange) Instantiate(ctx *interaction.Context, graph *interaction.Graph, rawInput interface{}) (interaction.Node, error) {
authenticator, reason, ok := graph.GetRequireUpdateAuthenticator(e.Stage)
if ok && authenticator.Type == model.AuthenticatorTypePassword {
return &NodeChangePasswordBegin{
Force: true,
Reason: reason,
Stage: e.Stage,
}, nil
}
return &NodeEnsurePasswordChange{
Stage: e.Stage,
}, nil
}
type NodeEnsurePasswordChange struct {
Stage authn.AuthenticationStage `json:"stage"`
}
func (n *NodeEnsurePasswordChange) Prepare(ctx *interaction.Context, graph *interaction.Graph) error {
return nil
}
func (n *NodeEnsurePasswordChange) GetEffects() ([]interaction.Effect, error) {
return nil, nil
}
func (n *NodeEnsurePasswordChange) DeriveEdges(graph *interaction.Graph) ([]interaction.Edge, error) {
return graph.Intent.DeriveEdgesForNode(graph, n)
}