fix the verification emails (#366)

* fix the verification emails

* fix typo

* switch to token only
This commit is contained in:
Asim Aslam
2022-02-09 21:51:47 +00:00
committed by GitHub
parent 1ea9b6f373
commit f232eab84e
5 changed files with 229 additions and 223 deletions

View File

@@ -17,12 +17,31 @@ func getStoreKeyPrefix(ctx context.Context) string {
return getStoreKeyPrefixForTenent(tenantId)
}
func getStoreKeyPrefixForTenent(tenantID string) string {
tid := strings.Replace(strings.Replace(tenantID, "/", "_", -1), "-", "_", -1)
func getTenantKey(ctx context.Context) string {
tenantId, ok := tenant.FromContext(ctx)
if !ok {
tenantId = "micro"
}
return strings.Replace(strings.Replace(tenantId, "/", "_", -1), "-", "_", -1)
}
func getStoreKeyPrefixForTenent(tenantId string) string {
tid := strings.Replace(strings.Replace(tenantId, "/", "_", -1), "-", "_", -1)
return fmt.Sprintf("user/%s/", tid)
}
func generateAccountTenantKey(tenantId, userId string) string {
return fmt.Sprintf("%saccount/id/%s", getStoreKeyPrefixForTenent(tenantId), userId)
}
func generateAccountTenantEmailKey(tenantId, email string) string {
return fmt.Sprintf("%sacccount/email/%s", getStoreKeyPrefixForTenent(tenantId), email)
}
func generateAccountTenantUsernameKey(tenantId, username string) string {
return fmt.Sprintf("%saccount/username/%s", getStoreKeyPrefixForTenent(tenantId), username)
}
func generateAccountStoreKey(ctx context.Context, userId string) string {
return fmt.Sprintf("%saccount/id/%s", getStoreKeyPrefix(ctx), userId)
}
@@ -47,6 +66,6 @@ func generateSessionStoreKey(ctx context.Context, sessionId string) string {
return fmt.Sprintf("%ssession/%s", getStoreKeyPrefix(ctx), sessionId)
}
func generateVerificationsTokenStoreKey(ctx context.Context, userId, token string) string {
return fmt.Sprintf("%sverification-token/%s-%s", getStoreKeyPrefix(ctx), userId, token)
func generateVerificationTokenStoreKey(token string) string {
return fmt.Sprintf("user/verification-token/%s", token)
}