cancel
Showing results for 
Search instead for 
Did you mean: 
hpkeong

How to Create UserName & UserID to improve Access Control

Assuming that you sign in PowerApps with a WorkMail, in your dept. but you have few users, and you wish to control who use the apps, access right, etc.

 

Though this may not be a good idea due to data security, but it is a way of designing control right.

 

Here I wish to share on how to create:

- UserName

 

- UserID

 

so as to control who can actually use / access the apps, especially navigation to those Screens confidential to particular users.

Meantime, you may also Save the UserName to trace the last sign in user.

 

  1. Let say you have a database with UserName and UserID

[In this case, I manually create one and show at the bottom of the age]

 

  1. Insert a Dropdown (name it as DDUserName) and tie it to:

Dropdown. Items

= Distinct(Passkey, UserName)

 

  1. Insert a TextInput box to enter UserID: Name it as TextUserID

 

  1. Insert a TextBox (or any other Icon, Button, etc.) with message to show up when UserName & UserID match each other.

 

So, please set the Visible of the TextBox to:

 

TextBox.Visible

 

= If(LookUp(Passkey, UserName = DDUserName.Selected.Result).UserID = TextUserID.Text, true, false)

 

The formula above says:

  1. LookUp the Table called Passkey, and if the UserName is same as UserName selected from Dropdown, check if the corresponding UserID match the TextInput data (as in TextUserID).
  2. If Yes, true – it will become Visible = true and show up. Otherwise, it will be ivisible.

 

Hope this simple formula will hlep to create PassKey by modifying my sample here.

 

 

 

Sample UserName & UserIDSample UserName & UserIDuserName.UserID = TextInputuserName.UserID = TextInputUserName <> UserIDUserName <> UserIDUserName.UserID = TextInputUserName.UserID = TextInput

 

Below Screenshots are the actual apps I have modified to use Number Key to suit today's trend. Just sharing.

 

Access Key Pad No,Access Key Pad No,Boss match with User ID..All Access Show-UpBoss match with User ID..All Access Show-UpAccess Control for employee.Access Control for employee.

 

Comments

 Hi!

 

Great idea! I would do it slightly different though, via the help of a settings table in your database and User().Fullname.

 

The advantages of this is that the users don't need to handle yet another password/passcode and the user also doesn't get the feeling that there are hidden things they cannot see, and they don't need to select their own name. Also, you don't need to add the administration burden of resetting the password if needed, but instead you would have to set each user's access flags. 

 

I would create a new table in the database, in this example called SECDB, containing all the settings your app needs, probably through bit-fields, and the user's full name as the key.

 

When the app starts, in the main form's OnVisible, do a lookup and save the settings in a record so you don't have to repeat the lookup all the time (unless of course, the settings change often):

UpdateContext({rUserSettings:Lookup(SECDB; User = User().Fullname)})

 

Now, in the textbox (or any other control), set the visible flag according to the settings in the user's record: 

 

TextBox.Visible: rUserSettings.ShowTextbox = true

Let's say there's a menu with administrator functions, show or hide it with something like below:

 

mnAdmin.Visible = rUSerSettings.IsAdmin = true

If would be even better if it was possible to add on the security settings in the built in User account, hence drop the need of an extra table. 

 

Hope this makes sense 🙂