fix: forgot password redirect from app
This commit is contained in:
parent
e690066652
commit
287b952dad
|
@ -60,7 +60,10 @@ export default function Login({ urlProps }: { urlProps: Record<string, any> }) {
|
||||||
{view === VIEW_TYPES.FORGOT_PASSWORD && (
|
{view === VIEW_TYPES.FORGOT_PASSWORD && (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<h1 style={{ textAlign: 'center' }}>Forgot Password</h1>
|
<h1 style={{ textAlign: 'center' }}>Forgot Password</h1>
|
||||||
<AuthorizerForgotPassword urlProps={urlProps} />
|
<AuthorizerForgotPassword urlProps={{
|
||||||
|
...urlProps,
|
||||||
|
redirect_uri: `${window.location.origin}/app/reset-password`,
|
||||||
|
}} />
|
||||||
<Footer>
|
<Footer>
|
||||||
<Link
|
<Link
|
||||||
to="#"
|
to="#"
|
||||||
|
|
|
@ -62,10 +62,24 @@ func ForgotPasswordResolver(ctx context.Context, params model.ForgotPasswordInpu
|
||||||
log.Debug("Failed to generate nonce: ", err)
|
log.Debug("Failed to generate nonce: ", err)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
redirectURI := parsers.GetAppURL(gc)
|
|
||||||
|
redirectURI := ""
|
||||||
|
// give higher preference to params redirect uri
|
||||||
if strings.TrimSpace(refs.StringValue(params.RedirectURI)) != "" {
|
if strings.TrimSpace(refs.StringValue(params.RedirectURI)) != "" {
|
||||||
|
fmt.Println("=> redirect uri from here1", redirectURI)
|
||||||
redirectURI = refs.StringValue(params.RedirectURI)
|
redirectURI = refs.StringValue(params.RedirectURI)
|
||||||
|
} else {
|
||||||
|
redirectURI, err = memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyResetPasswordURL)
|
||||||
|
fmt.Println("=> redirect uri from here2", redirectURI)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("ResetPasswordURL not found using default app url: ", err)
|
||||||
|
redirectURI = hostname + "/app/reset-password"
|
||||||
|
fmt.Println("=> redirect uri from here3", redirectURI)
|
||||||
|
memorystore.Provider.UpdateEnvVariable(constants.EnvKeyResetPasswordURL, redirectURI)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("=> redirect uri", redirectURI)
|
||||||
|
|
||||||
verificationToken, err := token.CreateVerificationToken(params.Email, constants.VerificationTypeForgotPassword, hostname, nonceHash, redirectURI)
|
verificationToken, err := token.CreateVerificationToken(params.Email, constants.VerificationTypeForgotPassword, hostname, nonceHash, redirectURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -89,7 +103,7 @@ func ForgotPasswordResolver(ctx context.Context, params model.ForgotPasswordInpu
|
||||||
go email.SendEmail([]string{params.Email}, constants.VerificationTypeForgotPassword, map[string]interface{}{
|
go email.SendEmail([]string{params.Email}, constants.VerificationTypeForgotPassword, map[string]interface{}{
|
||||||
"user": user.ToMap(),
|
"user": user.ToMap(),
|
||||||
"organization": utils.GetOrganization(),
|
"organization": utils.GetOrganization(),
|
||||||
"verification_url": utils.GetForgotPasswordURL(verificationToken, hostname, redirectURI),
|
"verification_url": utils.GetForgotPasswordURL(verificationToken, redirectURI),
|
||||||
})
|
})
|
||||||
|
|
||||||
res = &model.Response{
|
res = &model.Response{
|
||||||
|
|
|
@ -81,22 +81,8 @@ func GetOrganization() map[string]interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetForgotPasswordURL to get url for given token and hostname
|
// GetForgotPasswordURL to get url for given token and hostname
|
||||||
func GetForgotPasswordURL(token, hostname, redirectURI string) string {
|
func GetForgotPasswordURL(token, redirectURI string) string {
|
||||||
resetPasswordURL := redirectURI
|
verificationURL := redirectURI + "?token=" + token
|
||||||
|
|
||||||
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
|
|
||||||
return verificationURL
|
return verificationURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user