Get it right, or try again and again.
Following my thoughts from problem to solution, including the steps along the way, and the problems with each of them.
Or: How to login as a user from the Admin panel.

Joe: Hi Shuki.
Me: Hi Joe.
Joe: Remember the app you built me the other day?
Me: Of course.
Joe: Can you build me an option to login as any user from my Admin panel?
Me: Hmm. May I ask why?
Joe: For QA testing, anyways there is no sensitive data.
Me: I dunno.
Joe: Common, you’ll find a way.
Me: I’ll try.
If Stories & pictures aren’t your thing, you can jump to the solution.

users page
in the Admin panel, clicking any username
will open a new window, and login as that user.The problem:

The problem:

incognito mode
.The problem:

incognito mode
is not an option, we can add parameters to our site like: mysite.com/?user=john&pass=123
, and auto login when the page loads.The problem:

DevHelps
whatsapp group, where I got a quick and efficient solution.
If
you want to save parameters on the window, and can’t use cookies
because you want each window to have it’s own parameters, just use window.name
— Bnaya Peretz.
So My final Solution Has the following steps.
- On page loading check for a token saved in the
window.name
object,
if it exists, auto-login. Otherwise continue to login page. - After successful login, save the token to
window.name
for reloading. - When the admin, clicks on a username, open a new window named with that user’s token, which will auto login as the user.
- In the Admin panel display a popup to reload the page, and since
window.name
has the Admin’s token reloading will auto login as Admin.
0 comments :
Post a Comment