split sign and reset

This commit is contained in:
2025-01-30 11:33:16 -06:00
parent 597532bf26
commit 6dd84e4ca3
8 changed files with 441 additions and 47 deletions

View File

@@ -5,6 +5,7 @@ import (
"git.infra.nkode.tech/dkelly/nkode-core/config"
"git.infra.nkode.tech/dkelly/nkode-core/email"
"git.infra.nkode.tech/dkelly/nkode-core/entities"
"git.infra.nkode.tech/dkelly/nkode-core/memCache"
"git.infra.nkode.tech/dkelly/nkode-core/repository"
"git.infra.nkode.tech/dkelly/nkode-core/security"
"github.com/google/uuid"
@@ -23,6 +24,7 @@ type NKodeAPI struct {
repo repository.CustomerUserRepository
signupSessionCache *cache.Cache
emailQueue *email.Queue
forgotNkodeCache memCache.ForgotNKodeCache
}
func NewNKodeAPI(repo repository.CustomerUserRepository, queue *email.Queue) NKodeAPI {
@@ -30,6 +32,7 @@ func NewNKodeAPI(repo repository.CustomerUserRepository, queue *email.Queue) NKo
repo: repo,
emailQueue: queue,
signupSessionCache: cache.New(sessionExpiration, sessionCleanupInterval),
forgotNkodeCache: memCache.NewForgotNKodeCache(),
}
}
@@ -79,7 +82,6 @@ func (n *NKodeAPI) GenerateSignupResetInterface(userEmail entities.UserEmail, cu
return nil, err
}
svgInterface, err := n.repo.GetSvgStringInterface(signupSession.LoginUserInterface.SvgId)
if err != nil {
return nil, err
}
@@ -246,7 +248,7 @@ func (n *NKodeAPI) RefreshToken(userEmail entities.UserEmail, customerId entitie
return security.EncodeAndSignClaims(newAccessClaims)
}
func (n *NKodeAPI) ResetNKode(userEmail entities.UserEmail, customerId entities.CustomerId) error {
func (n *NKodeAPI) ForgotNKode(userEmail entities.UserEmail, customerId entities.CustomerId) error {
user, err := n.repo.GetUser(userEmail, customerId)
if err != nil {
return fmt.Errorf("error getting user in rest nkode %v", err)
@@ -272,6 +274,7 @@ func (n *NKodeAPI) ResetNKode(userEmail entities.UserEmail, customerId entities.
Content: htmlBody,
}
n.emailQueue.AddEmail(email)
n.forgotNkodeCache.Set(userEmail, customerId)
return nil
}