-
Notifications
You must be signed in to change notification settings - Fork 27
/
validate_user.go
45 lines (35 loc) · 1.06 KB
/
validate_user.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/apierrors"
"github.com/authgear/authgear-server/pkg/lib/interaction"
)
func init() {
interaction.RegisterNode(&NodeValidateUser{})
}
type EdgeValidateUser struct {
}
func (e *EdgeValidateUser) Instantiate(ctx *interaction.Context, graph *interaction.Graph, rawInput interface{}) (interaction.Node, error) {
u, err := ctx.Users.GetRaw(graph.MustGetUserID())
if err != nil {
return nil, err
}
var apiError *apierrors.APIError
if err := u.AccountStatus().Check(); err != nil {
apiError = apierrors.AsAPIError(err)
}
return &NodeValidateUser{
Error: apiError,
}, nil
}
type NodeValidateUser struct {
Error *apierrors.APIError `json:"error"`
}
func (n *NodeValidateUser) Prepare(ctx *interaction.Context, graph *interaction.Graph) error {
return nil
}
func (n *NodeValidateUser) GetEffects() ([]interaction.Effect, error) {
return nil, nil
}
func (n *NodeValidateUser) DeriveEdges(graph *interaction.Graph) ([]interaction.Edge, error) {
return graph.Intent.DeriveEdgesForNode(graph, n)
}