cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MustafaAlqanbar
Frequent Visitor

Redirect unauthorized user

I have an issue with Screen On visible parameter condition if user unauthorized else navigate, in case user is not authorized to view a specific in screen, then the user will be redirect to another screen. if there is any another option please provide me with a solution.    

 

 

 

If(
    IsBlank(
            Param("ID")
   ),
   0,
   If (
        LookUp(
                <<Table_Name>>, 
                <<Field_name>> = Param("ID"),
                <<Field_name>>
              ) = Office365Users.MyProfile().Mail,
        Param("ID"),
        Navigate(Auth_404)
      )
)

 

 

 

 

 Thanks in advanced

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @MustafaAlqanbar ,

Could you please share a bit more about the issue on your side?

Do you want to check if current sign in user is a authorized user, if yes, navigate him to the specific screen, if not, navigate to a Auth_404 screen?

 

Based on the formula you provided, I think you are in right direction. I have made a test on my side, please consider take a try with the following workaround:

Set the OnStart property of App to following:

If(
   !IsBlank(Param("ID")),
    If(
       LookUp(Table_Name, Field_Name = Param("ID"), Field_Name) = Office365Users.MyProfile().Mail,
       Navigate(SpecificScreen),   /* <-- Navigate to a specific screen */
       Navigate(Auth_404)          /* <-- Navigate to Auth_404 screen */
    )
)

In addition, it is not necessary to add Office 365 Users data source in your app, I think the User() function could achieve your needs. Please consider modify above formula as below:

If(
   !IsBlank(Param("ID")),
    If(
       LookUp(Table_Name, Field_Name = Param("ID"), Field_Name) = User().Email,
       Navigate(SpecificScreen),   /* <-- Navigate to a specific screen */
       Navigate(Auth_404)          /* <-- Navigate to Auth_404 screen */
    )
)

 

Actually, you could consider use a data source to store the authorized users, and then add this data source into your app. Then within your app, you could check if the current sign in user is existed in the data source directly. You could set the OnStart property of the App to following:

If(
   User().Email in Table_Name.EmailColumn,
   Navigate(SpecificScreen),
   Navigate(Auth_404)
)

or

If(
   User().FullName in Table_Name.DisplayNameColumn,
   Navigate(SpecificScreen),
   Navigate(Auth_404)
)

when your load your app, the above formula would be executed to check if the current sign in user is a authorized user.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @MustafaAlqanbar ,

Could you please share a bit more about the issue on your side?

Do you want to check if current sign in user is a authorized user, if yes, navigate him to the specific screen, if not, navigate to a Auth_404 screen?

 

Based on the formula you provided, I think you are in right direction. I have made a test on my side, please consider take a try with the following workaround:

Set the OnStart property of App to following:

If(
   !IsBlank(Param("ID")),
    If(
       LookUp(Table_Name, Field_Name = Param("ID"), Field_Name) = Office365Users.MyProfile().Mail,
       Navigate(SpecificScreen),   /* <-- Navigate to a specific screen */
       Navigate(Auth_404)          /* <-- Navigate to Auth_404 screen */
    )
)

In addition, it is not necessary to add Office 365 Users data source in your app, I think the User() function could achieve your needs. Please consider modify above formula as below:

If(
   !IsBlank(Param("ID")),
    If(
       LookUp(Table_Name, Field_Name = Param("ID"), Field_Name) = User().Email,
       Navigate(SpecificScreen),   /* <-- Navigate to a specific screen */
       Navigate(Auth_404)          /* <-- Navigate to Auth_404 screen */
    )
)

 

Actually, you could consider use a data source to store the authorized users, and then add this data source into your app. Then within your app, you could check if the current sign in user is existed in the data source directly. You could set the OnStart property of the App to following:

If(
   User().Email in Table_Name.EmailColumn,
   Navigate(SpecificScreen),
   Navigate(Auth_404)
)

or

If(
   User().FullName in Table_Name.DisplayNameColumn,
   Navigate(SpecificScreen),
   Navigate(Auth_404)
)

when your load your app, the above formula would be executed to check if the current sign in user is a authorized user.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi, this is great an I was using it. But now Powerapps It's not allowing to use the Navegate function OnStart. Please help.

thanks

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,667)