feature: verify tokens
This commit is contained in:
@@ -81,6 +81,18 @@ func (f UserSessionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserSessionMutation", m)
|
||||
}
|
||||
|
||||
// The VerifyTokenFunc type is an adapter to allow the use of ordinary
|
||||
// function as VerifyToken mutator.
|
||||
type VerifyTokenFunc func(context.Context, *ent.VerifyTokenMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f VerifyTokenFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.VerifyTokenMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.VerifyTokenMutation", m)
|
||||
}
|
||||
|
||||
// Condition is a hook condition function.
|
||||
type Condition func(context.Context, ent.Mutation) bool
|
||||
|
||||
|
Reference in New Issue
Block a user