使用承诺创建用户和登录流程 [英] createUser and login flow with promises
本文介绍了使用承诺创建用户和登录流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这个 git 问题 AngularFire 禁用了与 相关的自动登录功能$createUser
.(文档已过时.)>
那么创建用户然后登录的最佳实践/最简洁的方法是什么?
app.factory('Auth', function($firebaseSimpleLogin, FIREBASE_URL, $rootScope) {var ref = new Firebase(FIREBASE_URL);var auth = $firebaseSimpleLogin(ref);无功身份= {注册:功能(用户){返回 auth.$createUser(user.email, user.password);},登录:功能(用户){返回 auth.$login('密码', 用户);},...
注意:$createUser
返回 md5 哈希值,但 $login
使用明文密码.
我是 Promise 的新手.谢谢!
解决方案
我没明白加藤的意思.但现在我明白了 Promise 的解决方案非常简单:
注册:函数(用户){返回 auth.$createUser(user.email, user.password).then(function() {返回 auth.$login('密码', 用户);});},
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);
},
...
Note: $createUser
returns a md5 hash but $login
uses plaintext password.
I'm new to promises. Thanks!
解决方案
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);
});
},
这篇关于使用承诺创建用户和登录流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文