Forum Academy Marketplace Showcase Pricing Features

Im trying to allow my admin to switch to an employee view and account when a buttonis pressed. Any ideas on how to make this functionality

Im trying to allow my admin to switch to an employee view and account when a button is pressed. Any ideas on how to make this functionality?

He would like to see the employee view and be able to navigate through the app as any employee.

@dillonlucas

Consider building user roles functionality in your app.

Role (options set)
Display (admin, employee, role3, role3, etc)

User
Name (text)
Role (role options set)

@cmarchan
That was my initial thought on the matter but he is wondering if its possible to allow the admin to actually login as the user. So like a skeleton key for all of the accounts.

So the accounts would be listed with a repeating group and then they have a button in the cell would allow the admin to switch to the cell’s user’s profile but logged in as the cell’s user.

Two ways:

  1. Enable the admin role to have the same rights as any other role

or

  1. From the Bubble backend editor go to desired page and from the data tab in the user’s app data go to the page with “run as”

1 Like

@cmarchan

He is wanting that “run as” functionality without having to switch to the database. being able to access that function from the app through a button.

Option 1 :wink:

@cmarchan

How would you write that in the database?

@dillonlucas

@cmarchan

Thank you for the help!

1 Like

Hi there, @dillonlucas… looks like @cmarchan pointed you in a great direction, but I literally just implemented the feature you have described in one of my apps, so I thought it couldn’t hurt to throw something out there as food for thought.

Along with using an option set to define user roles, I added a field called view as (with a field type of User) to the User data type. Then, when an admin clicks one of the buttons in the repeating group, you make a change to the current user to set their view as field to the user associated with the button that was clicked. At that point, you can use the view as field across the app to drive searches and filters so the admin sees everything exactly as the associated user would. Changing the searches and filters is easily done with conditions that say when a user’s role is admin (or whatever), change the search/filter to use the view as field as opposed to current user.

Anyway, maybe that’s helpful and maybe it’s not, but it worked like a charm for me, and again, I didn’t think it could hurt to throw it out there.

Best…
Mike

2 Likes

@mikeloc

Thank you! I will definitely try this method.

1 Like