Redirecting customers to their home location when they try to log in via the network
  • 26 Jul 2023
  • 1 Minute to read
  • Dark
    Light

Redirecting customers to their home location when they try to log in via the network

  • Dark
    Light

Article summary

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.

  1. Log in to dashboard.nexudus.com if you aren't already.

  2. Click on the Pages & components folder. 

  3. Click Add file

  4. Name your file redirection.jsx and press Enter on your keyboard.

  5. 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;
  1. 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?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence