cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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

1 REPLY 1
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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (14,962)