2022-01-21 06:48:07 +00:00
|
|
|
package models
|
|
|
|
|
2022-01-25 05:27:40 +00:00
|
|
|
import "github.com/authorizerdev/authorizer/server/graph/model"
|
|
|
|
|
2022-01-21 06:48:07 +00:00
|
|
|
// VerificationRequest model for db
|
|
|
|
type VerificationRequest struct {
|
2022-04-20 18:02:02 +00:00
|
|
|
Key string `json:"_key,omitempty" bson:"_key" cql:"_key,omitempty"` // for arangodb
|
2022-03-19 12:11:27 +00:00
|
|
|
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id"`
|
|
|
|
Token string `gorm:"type:text" json:"token" bson:"token" cql:"token"`
|
2022-04-20 18:02:02 +00:00
|
|
|
Identifier string `gorm:"uniqueIndex:idx_email_identifier;type:varchar(64)" json:"identifier" bson:"identifier" cql:"identifier"`
|
2022-03-19 12:11:27 +00:00
|
|
|
ExpiresAt int64 `json:"expires_at" bson:"expires_at" cql:"expires_at"`
|
|
|
|
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at"`
|
|
|
|
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at"`
|
2022-04-20 18:02:02 +00:00
|
|
|
Email string `gorm:"uniqueIndex:idx_email_identifier;type:varchar(256)" json:"email" bson:"email" cql:"email"`
|
2022-03-19 12:11:27 +00:00
|
|
|
Nonce string `gorm:"type:text" json:"nonce" bson:"nonce" cql:"nonce"`
|
|
|
|
RedirectURI string `gorm:"type:text" json:"redirect_uri" bson:"redirect_uri" cql:"redirect_uri"`
|
2022-01-21 06:48:07 +00:00
|
|
|
}
|
2022-01-25 05:27:40 +00:00
|
|
|
|
|
|
|
func (v *VerificationRequest) AsAPIVerificationRequest() *model.VerificationRequest {
|
2022-03-16 16:14:57 +00:00
|
|
|
token := v.Token
|
|
|
|
createdAt := v.CreatedAt
|
|
|
|
updatedAt := v.UpdatedAt
|
|
|
|
email := v.Email
|
|
|
|
nonce := v.Nonce
|
|
|
|
redirectURI := v.RedirectURI
|
|
|
|
expires := v.ExpiresAt
|
|
|
|
identifier := v.Identifier
|
2022-01-25 05:27:40 +00:00
|
|
|
return &model.VerificationRequest{
|
2022-03-08 07:06:26 +00:00
|
|
|
ID: v.ID,
|
2022-03-16 16:14:57 +00:00
|
|
|
Token: &token,
|
|
|
|
Identifier: &identifier,
|
|
|
|
Expires: &expires,
|
|
|
|
CreatedAt: &createdAt,
|
|
|
|
UpdatedAt: &updatedAt,
|
|
|
|
Email: &email,
|
|
|
|
Nonce: &nonce,
|
|
|
|
RedirectURI: &redirectURI,
|
2022-01-25 05:27:40 +00:00
|
|
|
}
|
|
|
|
}
|