vtex-apps / login

Login docs and messages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

returnUrl in LoginContent

felipe-ssilva opened this issue · comments

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

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.

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

image