-
Notifications
You must be signed in to change notification settings - Fork 27
/
do_reset_lockout_attempts.go
41 lines (31 loc) · 1.12 KB
/
do_reset_lockout_attempts.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
package nodes
import (
"github.com/authgear/authgear-server/pkg/lib/interaction"
)
func init() {
interaction.RegisterNode(&NodeDoResetLockoutAttempts{})
}
type EdgeDoResetLockoutAttempts struct {
}
func (e *EdgeDoResetLockoutAttempts) Instantiate(ctx *interaction.Context, graph *interaction.Graph, rawInput interface{}) (interaction.Node, error) {
n := &NodeDoResetLockoutAttempts{}
return n, nil
}
type NodeDoResetLockoutAttempts struct {
}
func (n *NodeDoResetLockoutAttempts) Prepare(ctx *interaction.Context, graph *interaction.Graph) error {
return nil
}
func (n *NodeDoResetLockoutAttempts) GetEffects() ([]interaction.Effect, error) {
return []interaction.Effect{
interaction.EffectOnCommit(func(ctx *interaction.Context, graph *interaction.Graph, nodeIndex int) error {
userID := graph.MustGetUserID()
methods := graph.GetUsedAuthenticationLockoutMethods()
err := ctx.Authenticators.ClearLockoutAttempts(userID, methods)
return err
}),
}, nil
}
func (n *NodeDoResetLockoutAttempts) DeriveEdges(graph *interaction.Graph) ([]interaction.Edge, error) {
return graph.Intent.DeriveEdgesForNode(graph, n)
}