Redirecting customers to their home location when they try to log in via the network
- 26 Jul 2023
- 1 Minute to read
- DarkLight
Redirecting customers to their home location when they try to log in via the network
- Updated on 26 Jul 2023
- 1 Minute to read
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
This customization snippet lets you automatically redirect customers to their home location whenever they try to log in to your Members Portal via your network location.
This customization only works if you're using version 4 of the Members Portal.
Log in to dashboard.nexudus.com if you aren't already.
Click on the Pages & components folder.
Click Add file.
Name your file redirection.jsx and press Enter on your keyboard.
Add the following snippet to your file.
import React, { Component } from 'react';
import { inject, observer } from 'mobx-react';
import { withTranslation } from 'react-i18next';
import DefaultLayout from 'ui/layouts/DefaultLayout';
import Breadcrumbs from 'ui/components/Breadcrumbs';
import LoadingLayout from 'ui/layouts/LoadingLayout';
@withTranslation()
@inject('appStore', 'authStore')
@observer
class CustomPage extends Component {
componentDidMount() {
const { authStore, appStore } = this.props;
if(authStore.isLoggedIn){
setTimeout(async () => {
const me = await authStore.loadMe();
const homeSpace = appStore.businesses.find(b => b.Id == authStore.customer.HomeSpaceId);
if(homeSpace){
window.location = homeSpace.HomeUrl + `/login?t=${me.AccessToken}`;
}
}, 2000)
} else {
window.location = `/login?redirectUrl=${encodeURIComponent('/pages/sso')}`
}
}
render() {
return (
<LoadingLayout />
);
}
}
export default CustomPage;
Click the Save button.
All set! We recommend testing the customization by trying to log in from the network using a test customer account.
Was this article helpful?