cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Elitezone
Post Prodigy
Post Prodigy

Exit/reload app when rights taken away

Hello,

 

Is there a way to reload /exit app for user that have rights taken away?

I have a button function:

 

 

Remove(ListaAdmin,Gallery4.Selected);UpdateContext({showDialogAdmin:false});Notify("Administrator został usunięty!",NotificationType.Success)

 

 

with this I delete admins - but this works after next user session (app reload).

ListaAdmin is a sharepoint list with a field people that lists all users with particular rights (admins). It loads the list of users onStart of application.

Set(gblUserEmail,User().Email);Set(varAdmin1,false);Set(
   varAdmin,
   !IsBlank(
      LookUp(
         ListaAdmin,
         'Dane administratora'.Email=gblUserEmail
      )
   )
)

 

Is there a way to do something like that?

 

If not how can I incorporate a check if I deleted my own rights then exit? 

Or maybe a timer that check this rights in several minutes or something?

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@Elitezone 
I think the reason its still working on the next time the User opens an app is because Power Apps is being cached locally in the User's web browser.  Caching is a great way to improve app load speeds but it can cause problems like the one you described.

 

You could bypass this a couple of different ways.

 

#1.  Perform a check when the user enters the screen to see if they are still an Admin user.  Do this in the OnVisible property of the screen.

 

#2.  Perform a check every minute when the user is on a sensitive screen using a timer.  I don't like this idea though because it would make way too many calls.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

2 REPLIES 2
mdevaney
Super User
Super User

@Elitezone 
I think the reason its still working on the next time the User opens an app is because Power Apps is being cached locally in the User's web browser.  Caching is a great way to improve app load speeds but it can cause problems like the one you described.

 

You could bypass this a couple of different ways.

 

#1.  Perform a check when the user enters the screen to see if they are still an Admin user.  Do this in the OnVisible property of the screen.

 

#2.  Perform a check every minute when the user is on a sensitive screen using a timer.  I don't like this idea though because it would make way too many calls.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Ok. I have added it on some screens, seems to be working sometimes... but not always...

Can it be done with IF statement?

 

Set(
   varAdmin,
   !IsBlank(
      LookUp(
         ListaAdmin,
         'Dane administratora'.Email=gblUserEmail
      )
   )

 

 

 

 

For example - first this check it sets varAdmin.

If varAdmin is false then navigate to different screen or exit.

 

Seems to have made something like that:

 

 

 

showDialogAdmin=false;Set(
   varAdmin,
   !IsBlank(
      LookUp(
         ListaAdmin,
         'Dane administratora'.Email=gblUserEmail
      )));If(varAdmin=false,Navigate(Screen1;Fade))

 

 

 

But wish I could make it on change in gallery or form.

it spams a bit of errors mostly.

And the new one for me - navigate cannot be used in onVisible.

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,004)