Added password token entity.
This commit is contained in:
parent
1ac68b7d9f
commit
c9d50cb3d4
25 changed files with 3489 additions and 20 deletions
35
ent/schema/passwordtoken.go
Normal file
35
ent/schema/passwordtoken.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// PasswordToken holds the schema definition for the PasswordToken entity.
|
||||
type PasswordToken struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the PasswordToken.
|
||||
func (PasswordToken) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("hash").
|
||||
Sensitive().
|
||||
NotEmpty(),
|
||||
field.Time("created_at").
|
||||
Default(time.Now).
|
||||
Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the PasswordToken.
|
||||
func (PasswordToken) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("user", User.Type).
|
||||
Required().
|
||||
Unique(),
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
|
|
@ -31,5 +32,8 @@ func (User) Fields() []ent.Field {
|
|||
|
||||
// Edges of the User.
|
||||
func (User) Edges() []ent.Edge {
|
||||
return nil
|
||||
return []ent.Edge{
|
||||
edge.From("owner", PasswordToken.Type).
|
||||
Ref("user"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue