Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

returnUrl in LoginContent #16

Open
felipe-ssilva opened this issue Jun 8, 2022 · 4 comments
Open

returnUrl in LoginContent #16

felipe-ssilva opened this issue Jun 8, 2022 · 4 comments

Comments

@felipe-ssilva
Copy link

Hi guys! How it's going?

How using returnUrl in LoginContent? This is possible?
The login is working. But returnUrl after login not.

import LoginContent from 'vtex.login/LoginContent'; 

 <LoginContent
          profile={profile}
          defaultOption={1}
          returnUrl={encodeURIComponent(urlLocal)}
          emailAndPasswordTitle={`Entrar com e-mail e senha:`}
          optionsTitle={`Use uma das opções abaixo:`}
          accessCodeTitle="Receber código de acesso por e-mail"
          emailPlaceholder="Digite seu e-mail"
          passwordPlaceholder="Digite sua senha"
          accessCodePlaceholder="Digite seu código"
          isInitialScreenOptionOnly={false}
          showPasswordVerificationIntoTooltip={true}
/>

Custom app:
image

@charzlwebz256
Copy link

Yes, it's possible to use the returnUrl prop in the LoginContent component to redirect the user to a specific page after they log in. Here's an example of how you can use it:
`import LoginContent from 'vtex.login/LoginContent';

const MyLoginPage = () => {
const returnUrl = encodeURIComponent('https://example.com/my-account');

return (
<LoginContent
profile={profile}
defaultOption={1}
returnUrl={returnUrl}
emailAndPasswordTitle={Entrar com e-mail e senha:}
optionsTitle={Use uma das opções abaixo:}
accessCodeTitle="Receber código de acesso por e-mail"
emailPlaceholder="Digite seu e-mail"
passwordPlaceholder="Digite sua senha"
accessCodePlaceholder="Digite seu código"
isInitialScreenOptionOnly={false}
showPasswordVerificationIntoTooltip={true}
/>
);
};
`
In this example, the returnUrl prop is set to https://example.com/my-account, which is the URL that the user will be redirected to after they log in. Make sure to encode the URL using the encodeURIComponent function, as shown in the example.

When the user logs in, they will be redirected to the URL specified in the returnUrl prop. If the returnUrl prop is not specified or is set to an empty string, the user will be redirected to the home page of the website.

@Abongile184
Copy link

Abongile184 commented Feb 27, 2023 via email

@manutromero
Copy link

@charzlwebz256 But, how you imported vtex.login: "2.x" in you manifest? I got this error.

image

@nohestmm
Copy link

Hi, not work for me, did it work for anyone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants