implemented verifiaction db
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"github.com/tech/sendico/pkg/mservice"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
@@ -27,11 +29,10 @@ type AccountPublic struct {
|
||||
}
|
||||
|
||||
type Account struct {
|
||||
AccountPublic `bson:",inline" json:",inline"`
|
||||
EmailBackup string `bson:"emailBackup" json:"emailBackup"`
|
||||
Password string `bson:"password" json:"password"`
|
||||
ResetPasswordToken string `bson:"resetPasswordToken" json:"resetPasswordToken"`
|
||||
VerifyToken string `bson:"verifyToken" json:"verifyToken"`
|
||||
AccountPublic `bson:",inline" json:",inline"`
|
||||
EmailBackup string `bson:"emailBackup" json:"-"`
|
||||
Password string `bson:"password" json:"-"` // password hash
|
||||
EmailVerifiedAt *time.Time `bson:"emailVerifiedAt,omitempty" json:"-"`
|
||||
}
|
||||
|
||||
func (a *Account) HashPassword() error {
|
||||
|
||||
30
api/pkg/model/verificaton.go
Normal file
30
api/pkg/model/verificaton.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
type VerificationPurpose string
|
||||
|
||||
const (
|
||||
PurposeAccountActivation VerificationPurpose = "account_activation"
|
||||
PurposeEmailChange VerificationPurpose = "email_change"
|
||||
PurposePasswordReset VerificationPurpose = "password_reset"
|
||||
PurposeSensitiveAction VerificationPurpose = "sensitive_action"
|
||||
PurposeMagicLogin VerificationPurpose = "magic_login"
|
||||
)
|
||||
|
||||
type VerificationToken struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
ArchivableBase `bson:",inline" json:",inline"`
|
||||
|
||||
Target string `bson:"target,omitempty" json:"target"`
|
||||
AccountRef bson.ObjectID `bson:"accountRef" json:"accountRef"`
|
||||
Purpose VerificationPurpose `bson:"purpose" json:"purpose"`
|
||||
VerifyTokenHash string `bson:"verifyTokenHash" json:"-"`
|
||||
UsedAt *time.Time `bson:"usedAt,omitempty" json:"-"`
|
||||
ExpiresAt time.Time `bson:"expiresAt" json:"-"`
|
||||
}
|
||||
Reference in New Issue
Block a user