Render IO app that replaces vtex.login to support the alternative login with username method (a temporary B2B solution created for the ODP project).
Configuration
- Add the Login app to your theme's dependencies in the
manifest.jsonfile:
_10 "dependencies": {_10+ "vtex.login-alternative-key": "1.x"_10 }
Now, you are able to use all the blocks exported by the Login with Alternative Key app. Check out the full list below:
| Block name | Description |
|---|---|
login | Only renders a "Login" button that redirects to the login page. |
login-content |
- Add the
vtex.login-alternative-keyapp to your custom store theme dependencies:
manifest.json
_10"dependencies": {_10 "vtex.store": "2.x",_10 "vtex.login-alternative-key": "1.x",_10}
If you used the
vtex.store-themetemplate, remove thevtex.logindependency.
_10+ "vtex.login-alternative-key": "1.x",_10- "vtex.login": "2.x",
- Add the
login-contentblock to your custom store theme's login page. It must implement thestore.logininterface fromvtex.store:
blocks.json
_10"store.login": {_10 "blocks": [_10 "login-content"_10 ]_10},
Ensure the
store.loginimplementation is only declared once. If you used thevtex.store-themetemplate, remove thelogin-content#defaultblock and its props.
_10+ "blocks": ["login-content"]_10- "blocks": ["login-content#default"]
_10- "login-content#default": {_10- "props": {_10- "isInitialScreenOptionOnly": false,_10- "defaultOption": 1,_10- "showPasswordVerificationIntoTooltip": true_10- }_10- },
- Optionally, add the
loginblock to your store's header. For example:
_10"flex-layout.row#4-desktop": {_10 "children": [_10 "login"_10 ]_10},
Modus Operandi
The Login with Alternative Key app reads the following query-string parameters:
returnUrl- Redirects users to the givenreturnUrlonce they are logged in. Caution: This parameter only works for the store's domain and should be UTF-8 encoded (as in javascript'sencodeURIComponent).
Customization
In order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on Using CSS Handles for store customization.
| CSS Handles |
|---|
loginContainer |
userIdentificationContainer |
userIdentificationTitle |
userIdentificationForm |
userIdentificationInput |
userIdentificationOptions |
userIdentificationSignUp |
userIdentificationContinueButton |
passwordLoginContainer |
passwordLoginTitle |
passwordLoginForm |
passwordLoginInputs |
passwordLoginError |
passwordLoginOptions |
passwordLoginButtons |
passwordLoginSignUp |
passwordLoginBackButton |
passwordLoginSignInButton |
passwordCreationContainer |
passwordCreationTexts |
passwordCreationTitle |
passwordCreationDescription |
passwordCreationForm |
passwordCreationInputs |
passwordCreationInputPassword |
passwordCreationOptions |
passwordCreationBackButton |
passwordCreationSignInButton |
passwordCreationPasswordRequirementsContainer |
passwordCreationPasswordRequirementsTitle |
passwordCreationPasswordRequirementsList |
passwordCreationPasswordRequirementsItem |
passwordCreationError |
How to run the project
After logging into a test account and using a custom workspace, to see the changes made to that app, we need to link it with the command:
vtex link
However, since this app is not included in the default store theme, you'll need to modify an additional app to test these changes.
Edit the store-theme app
-
Clone the app from this repository
-
Edit the
blocks.jsoncfile:
_10+ "blocks": ["login-content"]_10- "blocks": ["login-content#default"]
_10- "login-content#default": {_10- "props": {_10- "isInitialScreenOptionOnly": false,_10- "defaultOption": 1,_10- "showPasswordVerificationIntoTooltip": true_10- }_10- },
- Edit the
manifest.jsonfile:
_10+ "vtex.login-alternative-key": "1.x",_10- "vtex.login": "2.x",
- Link the app
vtex link
You just need to link that once per workspace, so you don't need to keep this linked while making your changes to the
login-alternative-keyapp.