fixed verification code

This commit is contained in:
Stephan D
2026-02-09 16:40:52 +01:00
parent f8a3bef2e6
commit eda6b75f74
78 changed files with 1118 additions and 487 deletions

View File

@@ -12,12 +12,14 @@ import (
type AccountNotification struct {
messaging.Envelope
accountRef bson.ObjectID
accountRef bson.ObjectID
verificationToken string
}
func (acn *AccountNotification) Serialize() ([]byte, error) {
var msg gmessaging.AccountCreatedEvent
msg.AccountRef = acn.accountRef.Hex()
msg.VerificationToken = acn.verificationToken
data, err := proto.Marshal(&msg)
if err != nil {
return nil, err
@@ -29,9 +31,10 @@ func NewAccountNotification(action nm.NotificationAction) model.NotificationEven
return model.NewNotification(mservice.Accounts, action)
}
func NewAccountImp(sender string, accountRef bson.ObjectID, action nm.NotificationAction) messaging.Envelope {
func NewAccountImp(sender string, accountRef bson.ObjectID, action nm.NotificationAction, verificationToken string) messaging.Envelope {
return &AccountNotification{
Envelope: messaging.CreateEnvelope(sender, NewAccountNotification(action)),
accountRef: accountRef,
Envelope: messaging.CreateEnvelope(sender, NewAccountNotification(action)),
accountRef: accountRef,
verificationToken: verificationToken,
}
}

View File

@@ -34,12 +34,13 @@ func (acnp *AccoountNotificaionProcessor) Process(ctx context.Context, envelope
acnp.logger.Warn("Failed to restore object ID", zap.Error(err), zap.String("topic", acnp.event.ToString()), zap.String("account_ref", msg.AccountRef))
return err
}
verificationToken := msg.GetVerificationToken()
var account model.Account
if err := acnp.db.Get(ctx, accountRef, &account); err != nil {
acnp.logger.Warn("Failed to fetch account", zap.Error(err), zap.String("topic", acnp.event.ToString()), zap.String("account_ref", msg.AccountRef))
return err
}
return acnp.handler(ctx, &account)
return acnp.handler(ctx, &account, verificationToken)
}
func (acnp *AccoountNotificaionProcessor) GetSubject() model.NotificationEvent {