fix(server):give higher preference to redirect_uri

While using forgot_password redirect URI was ignored if not present

Resolves #275
This commit is contained in:
Lakhan Samani
2022-10-24 11:15:36 +05:30
parent 6e09307c22
commit e690066652
2 changed files with 18 additions and 13 deletions

View File

@@ -81,17 +81,22 @@ func GetOrganization() map[string]interface{} {
}
// 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 {
func GetForgotPasswordURL(token, hostname, redirectURI string) string {
resetPasswordURL := redirectURI
if resetPasswordURL == "" {
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
verificationURL := resetPasswordURL + "?token=" + token
return verificationURL
}