简体   繁体   English

Parse.com - 如何在不知道密码的情况下以用户身份登录?

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

I'm using Parse.com, and like it a lot. 我正在使用Parse.com,并且喜欢它。

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. 我希望我的应用程序的用户自动分配一个帐户(我使用Parse API在幕后创建),然后将其登录到他们的帐户中。

I could easily do this if I assigned them a hard coded, standard password for their account, eg superPass123. 如果我为他们的帐户分配了一个硬编码的标准密码,例如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? 或者是否有其他方式允许我在不知道用户密码的情况下以用户身份自动登录,如果我的用户具有“超级”权限?

If you secure it enough, you can essentially do this by using Cloud Code. 如果您足够安全,您可以使用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. cloud函数将用户会话令牌返回给客户端(user.getSessionToken()),该客户端使用“成为”功能以该用户身份登录。

Relevant posts: 相关帖子:

Announcing the "become" feature: http://blog.parse.com/2013/12/03/bring-your-own-login/ 宣布“成为”功能: 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 涵盖提供会话令牌的云代码实现的教程: https//parse.com/tutorials/adding-third-party-authentication-to-your-web-app

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM