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 && (
|
||||
<Fragment>
|
||||
<h1 style={{ textAlign: 'center' }}>Forgot Password</h1>
|
||||
<AuthorizerForgotPassword urlProps={urlProps} />
|
||||
<AuthorizerForgotPassword urlProps={{
|
||||
...urlProps,
|
||||
redirect_uri: `${window.location.origin}/app/reset-password`,
|
||||
}} />
|
||||
<Footer>
|
||||
<Link
|
||||
to="#"
|
||||
|
|
|
@ -62,11 +62,25 @@ func ForgotPasswordResolver(ctx context.Context, params model.ForgotPasswordInpu
|
|||
log.Debug("Failed to generate nonce: ", err)
|
||||
return res, err
|
||||
}
|
||||
redirectURI := parsers.GetAppURL(gc)
|
||||
|
||||
redirectURI := ""
|
||||
// give higher preference to params redirect uri
|
||||
if strings.TrimSpace(refs.StringValue(params.RedirectURI)) != "" {
|
||||
fmt.Println("=> redirect uri from here1", 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)
|
||||
if err != nil {
|
||||
log.Debug("Failed to create verification token", err)
|
||||
|
@ -89,7 +103,7 @@ func ForgotPasswordResolver(ctx context.Context, params model.ForgotPasswordInpu
|
|||
go email.SendEmail([]string{params.Email}, constants.VerificationTypeForgotPassword, map[string]interface{}{
|
||||
"user": user.ToMap(),
|
||||
"organization": utils.GetOrganization(),
|
||||
"verification_url": utils.GetForgotPasswordURL(verificationToken, hostname, redirectURI),
|
||||
"verification_url": utils.GetForgotPasswordURL(verificationToken, redirectURI),
|
||||
})
|
||||
|
||||
res = &model.Response{
|
||||
|
|
|
@ -81,22 +81,8 @@ func GetOrganization() map[string]interface{} {
|
|||
}
|
||||
|
||||
// GetForgotPasswordURL to get url for given token and hostname
|
||||
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
|
||||
func GetForgotPasswordURL(token, redirectURI string) string {
|
||||
verificationURL := redirectURI + "?token=" + token
|
||||
return verificationURL
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user