小编Nic*_*ton的帖子

使用Firebase simplelogin实施唯一的用户名

我最近在Thinkster学习了一个使用Angular和Firebase创建Web应用程序的教程.

本教程使用Firebase simpleLogin方法允许创建包含用户名的"配置文件".

厂:

app.factory('Auth', function($firebaseSimpleLogin, $firebase, 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);
    },
    createProfile: function(user) {
        var profile = {
            username: user.username,
            md5_hash: user.md5_hash
        };

        var profileRef = $firebase(ref.child('profile'));
        return profileRef.$set(user.uid, profile);
    },
    login: function(user) {
        return auth.$login('password', user);
    },
    logout: function() {
        auth.$logout();
    },
    resolveUser: function() {
        return auth.$getCurrentUser();
    },
    signedIn: function() {
        return !!Auth.user.provider;
    },
    user: {} …
Run Code Online (Sandbox Code Playgroud)

angularjs firebase angularfire

9
推荐指数
1
解决办法
4546
查看次数

标签 统计

angularfire ×1

angularjs ×1

firebase ×1