Retrieve a list of user data and make a different interface response

For my custom alarm panel integration (Visonic here) I would like to make a difference between users for whether the keypad is shown or not (to arm and disarm the panel). So for example, a tablet mounted on a wall in the house would always show the keypad to disarm the alarm but other users may have direct access from their mobile phones and not show the keypad.

Can this be achieved? Would Home Assistant be able to make this difference based on the user or are all users given the same interface?

If it is possible then is there a way to get the user information from a custom component. I would like to get the list of users, the names, whether it is a system generated user and if it is active. Essentially I want the information in the auth file but from a supported function call rather than me opening the auth file from my custom component :slight_smile: .

EDIT: After looking through the Home Assistant code and google I found async_get_users() that I can use like this:

users = await hass.auth.async_get_users()

I tried it from my custom component and it gives me a list of users with lots of other information but I can extract out what I need.

How do I get the current user (in the backend remember, not the frontend).

EDIT: From more googling and reading it looks like I cannot get the current user in the backend, it is a frontend thing only. I’m not 100% on this so I’m willing to be corrected. Assuming this is correct, plus the fact that code_format in the backend is called from the frontend to determine if the keypad is displayed (and what type of keypad), is it possible to add a parameter to code_format function that provides the current users name. The frontend and backend would need to be changed. I’m a python person and not a frontend person so I wouldn’t know where to start. In the backend it could be an optional parameter to code_format to make it backward compatable.

You can have a dashboard only be accessible by an admin user. Hopefully a more flexible user access will come.