cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MustafaAlqanbar
Level: Powered On

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
Community Support Team
Community Support Team

Re: Redirect unauthorized user

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

1 REPLY 1
Community Support Team
Community Support Team

Re: Redirect unauthorized user

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,403)