cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MO4
Helper I
Helper I

Hiding web page from Authenticate Users and allowing Anonymous Users to access it

I have a requirement to allow access to a web page to Anonymous Users but once any users logged-in then restrict access to that page or logged-in users. I tried with Web Role but it didn't work

 

Any solutions ?

Thanks

 

Regards 

MO

7 REPLIES 7
Anonymous
Not applicable

Hi @MO4 

 

Create a Web Page Access Control Rules and add the Web roles to those rules to hide for Authenticated users but show for Anonymous Users.

 

Please link and Accept it as a Solution if it helps you.

Thanks,

Amit

I tried the given solution. But its hiding the page from anonymous users also. It don't work. 

Thanks for reply. 😉

Hi @MO4 ,

 

The solution proposed by @Anonymous  should work. Another way to achieve this is if you create a web template for your page by yourself in liquid. Then you can easily have a condition like below to show content depending if user is logged in or not.

{% if user %}
// CONTENT FOR LOGGED IN USER
{% else %}
// CONTENT FOR ANON USERS
{% endif %}

 

----------------------------------------------------
If you find this post helpful consider marking it as a solution to help others find it.

Hi @OOlashyn thanks for reply 

 

i want to hide button from navbar once any users logged-in the button should disappear

 

button.PNG

Hi @MO4 ,

 

Usually, when you do it vice-verse ie restrict access to a web page by specific role with web page access control rules it will automatically remove the link from the header because of the access permissions. However, with the anonymous user, I would suggest modifying Header web template with liquid to see if a user is logged in and if the page is the one you need to hide and just skip it's rendering. 

 

----------------------------------------------------
If you find this post helpful consider marking it as a solution to help others find it.

Web Page Control Access work only for authenticated type Web Roles as far as I know

there are a few options to achieve your need:

 

  • you can create two different Web Link Sets, one representing the authenticated, and other the anonymous, and define Web Links for each.. then go to your Header Web Template find the line that calls the Web Link Set (the web link set is usually called Default or Primary Navigation) and add the validation mentioned by @OOlashyn, so if you can set different Web Link Set according to the user sign-in state
    • only problem here is that you would end up with two web link sets to maintain.. every new link in the header you have to add twice
  • other option would be adding a custom attribute to your Web Link entity, something like Hide if user Signed In.. and make changes in your Header Web Template adding the validation when rendering the Web Link itself

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.




If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Apps Portals Super User


Oliver Rodrigues


 

MRown
Frequent Visitor

Thanks this worked for my needs

&   thanks @OliverRodrigues

 

for anyone trying to get this to work here's my example:
of course add your own Weblink Sets instead of ("User+Guest weblink sets") in the {% assign primary_nav=}:

 

 </div>
        <div id="navbar" class="navbar-collapse collapse">
        {% if user %}
        {% assign primary_nav = weblinks["User Weblink Set"] %}
        {% else %}
        {% assign primary_nav = weblinks["Guest Weblink Set"] %}
        {% endif %}

            {% if primary_nav %}
----------------​

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Users online (22,355)