的createUser和承诺登录流程 [英] createUser and login flow with promises
本文介绍了的createUser和承诺登录流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这个混帐问题 AngularFire禁用与<$ C相关的自动登录功能$ C> $的createUser 。 ( 是过时的文档。)
In this git issue AngularFire disabled the auto-login functionality associated with $createUser
. (The docs are outdated.)
那么,什么是创建一个用户,然后在记录他们的最佳实践/干净的方式?
So what's the best practice / cleanest way to create a user and then log them in?
app.factory('Auth', function($firebaseSimpleLogin, FIREBASE_URL, $rootScope) {
var ref = new Firebase(FIREBASE_URL);
var auth = $firebaseSimpleLogin(ref);
var Auth = {
register: function (user) {
return auth.$createUser(user.email, user.password);
},
login: function (user) {
return auth.$login('password', user);
},
...
请注意: $的createUser
返回一个MD5哈希值,但是的 $登录
使用明文密码。
Note: $createUser
returns a md5 hash but $login
uses plaintext password.
我是新来的承诺。谢谢!
I'm new to promises. Thanks!
推荐答案
我不知道是什么意思加藤。但现在,我明白承诺的解决方案是pretty直截了当:
I didn't realize what Kato meant. But now that I understand promises the solution is pretty straight forward:
register: function (user) {
return auth.$createUser(user.email, user.password)
.then(function() {
return auth.$login('password', user);
});
},
这篇关于的createUser和承诺登录流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文