2014-02-25 30 views
0

如果我使用火力的simpleLogin与Facebook作为供应商登记和用户信息保存到我的火力点,如果用户已经在数据库中的条目将它不重复的条目。使用火力simplelogin Facebook和angularjs坚持信息火力

在我的控制器,但可能不正确的地方注册用户:

$scope.login = function(service) { 
    simpleLogin.login(service, function(err, user) { 
    $scope.err = err? err + '' : null; 
    // on login what are you gonna do with the profile info 
    // probably save a copy in firebase 

    }); 
}; 

我应该保存在我的控制器在功能的用户信息?这里是我的登录工厂,因为我有一种预感,大大节省了用户应该就在这里进行。

return { 
    init: function() { 
    auth = $firebaseSimpleLogin(firebaseRef()); 
    return auth; 
    }, 
    logout: function() { 
    assertAuth(); 
    auth.$logout(); 
    }, 
    login: function(provider, callback) { 
    // check if app is authorized, then login if yes 
    assertAuth(); 
    auth.$login(provider, {rememberMe: true}).then(function(user) { 
     if(callback) { 
     //todo-bug https://github.com/firebase/angularFire/issues/199 
     $timeout(function() { 
      callback(null, user); 
     }); 
     } 
    }, callback); 
    } 
}; 

回答

0

这取决于您是否将“user”用作视图的一部分,然后将其绑定到控制器中的作用域对象。如果没有,创建一个名为用户在工厂本地对象,并参考它。