feature: verify tokens

This commit is contained in:
2024-11-17 22:28:29 +05:30
parent 26a00c9f7c
commit 9d40c9d7ec
57 changed files with 4188 additions and 276 deletions

View File

@@ -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