Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse.com - How to login as a user without knowing their password?

I'm using Parse.com, and like it a lot.

I'd like users of my app to automatically be assigned an account (which I create behind the scenes using the Parse API) and then log them into their account.

I could easily do this if I assigned them a hard coded, standard password for their account, e.g superPass123.

Is this the only way I can do this? Or is there some other way to allow me to login automatically as a user without knowing a users password, if my user has "super" rights?

like image 691
Brad Parks Avatar asked Jul 05 '14 00:07

Brad Parks


Video Answer


1 Answers

If you secure it enough, you can essentially do this by using Cloud Code. I'll skip over the validation/authorization part, and focus on how.

A cloud function, which, running with the Master Key, can query for a user. The cloud function returns the users session token to the client (user.getSessionToken()), which uses the "become" functionality to log in as that user.

Relevant posts:

Announcing the "become" feature: http://blog.parse.com/2013/12/03/bring-your-own-login/

Tutorial that covers an implementation of cloud code providing a session token: https://parse.com/tutorials/adding-third-party-authentication-to-your-web-app

like image 133
Fosco Avatar answered Nov 03 '22 22:11

Fosco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!