feat: send email based on template
This commit is contained in:
@@ -2,6 +2,9 @@ package utils
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/authorizerdev/authorizer/server/constants"
|
||||
"github.com/authorizerdev/authorizer/server/memorystore"
|
||||
)
|
||||
|
||||
// StringSliceContains checks if a string slice contains a particular string
|
||||
@@ -58,3 +61,46 @@ func ConvertInterfaceToStringSlice(slice interface{}) []string {
|
||||
}
|
||||
return resSlice
|
||||
}
|
||||
|
||||
// GetOrganization to get organization object
|
||||
func GetOrganization() map[string]interface{} {
|
||||
orgLogo, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyOrganizationLogo)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
orgName, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyOrganizationName)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
organization := map[string]interface{}{
|
||||
"name": orgName,
|
||||
"logo": orgLogo,
|
||||
}
|
||||
|
||||
return organization
|
||||
}
|
||||
|
||||
// GetForgotPasswordURL to get url for given token and hostname
|
||||
func GetForgotPasswordURL(token, hostname string) string {
|
||||
resetPasswordUrl, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyResetPasswordURL)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if resetPasswordUrl == "" {
|
||||
if err := memorystore.Provider.UpdateEnvVariable(constants.EnvKeyResetPasswordURL, hostname+"/app/reset-password"); err != nil {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
verificationURL := resetPasswordUrl + "?token=" + token
|
||||
return verificationURL
|
||||
}
|
||||
|
||||
// GetInviteVerificationURL to get url for invite email verification
|
||||
func GetInviteVerificationURL(verificationURL, token, redirectURI string) string {
|
||||
return verificationURL + "?token=" + token + "&redirect_uri=" + redirectURI
|
||||
}
|
||||
|
||||
// GetEmailVerificationURL to get url for invite email verification
|
||||
func GetEmailVerificationURL(token, hostname string) string {
|
||||
return hostname + "/verify_email?token=" + token
|
||||
}
|
||||
|
Reference in New Issue
Block a user