web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Power Pages – Redirect...
Power Pages
Suggested Answer

Power Pages – Redirect users after login based on email domain

(0) ShareShare
ReportReport
Posted on by 49
Hello everyone,

I’m working with Power Pages and I’m trying to redirect users to different pages after login, based on their email domain.
Scenario
  • The Home Page Partial URL is set to / (as required by Power Pages).
  • I have created separate pages such as:
    • /Samsung
    • /Test
    • etc.
  • Users sign in using username and password, not email.
  • However, each user account is linked to an email address, for example:
    • sam3311@samsung.com
    • john123@test.com
  • Each domain has multiple users, and I may have around 5 different domains, each needing to redirect to a specific page.
What I tried

I added the following script at the top of the Home page, before the HTML:
<script>
  window.location.href = "/Samsung";
</script>

Issues
  1. After signing in, users are redirected correctly to /Samsung.
  2. However, when the user later clicks on “Home”, it always redirects back to /Samsung.
  3. This means the Home page (/) is no longer accessible.
What I want to achieve
  • Keep the Home page Partial URL as /.
  • Redirect users only after login, based on their email domain:
    • @samsung.com → /Samsung
    • @test.com → /Test
    • etc.
  • Allow users to access the Home page normally when clicking “Home”.
  • Implement a domain-based redirect logic that works even though users log in using username/password.
Question
  • Detect the logged-in user’s email domain
  • Redirect them after login to a domain-specific page
  • Without breaking access to the Home page (/)?
Any guidance or best practice would be greatly appreciated.

Thank you!
Categories:
I have the same question (2)
  • Suggested answer
    Fubar Profile Picture
    8,379 Super User 2025 Season 2 on at
    If it is stored against the contact (e.g. either inviting the contact to use the system or it is set as a mandatory field during registration/profile) getting the users email address is the easy bit - use the Liquid 'user' object (which is the users Contact record) so something like {{ users.emailaddress1 }}
     
    You can set to a JavaScript variable (and then extract the domain with JavaScript)
    <script>
      var theEmail = {{ users.emailaddress1 }};
    
    </script>
    or
     
    You could extract the domain from the contacts email in Liquid by using a split on the at symbol (and then putting the result into a JavaScript variable)
     
    The issue is the redirect as you only want it on the first time, and there isn't any standard way of detecting this (and the only way to redirect is in JavaScript). One thing you can do is make use of javascript local storage - e.g. check for a local storage variable if not present create it & then JS redirect, if not present no redirect. Check for the local storage inside a Liquid if that checks for the 'user' object existence
    {% if user %}
    
      <script>
        // check for local storage variable
        // if not found create it & then JS redirect
      </script>
     
    {% endif %}
     
    Depending on what you are doing you may put this type of code in the Web Page in question or the Header or Footer Web Template
     
    Note: the local storage will exist while the browser is open, i.e. it won't clear if they manually sign out - if this is an issue - you can clear it when the 'user' object does not exist ('user' only exists when the user is logged in), basically do an Liquid if user as above but add an {% else %} for when the user is logged out. If taking this approach you may choose to put it in the header/footer web template so it happens on any page if the user is signed out. 
     
     
    Note2: if putting in the Header/Footer you will probably need to turn off the header/footer caching or wrap the code in a substitution block (other wise it will not re-evaluate on each page load)
     
     
     
     
     
     
     
     
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 89 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 75

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard