mrt add accounts-password mrt add accounts-facebook mrt add accounts-twitter
mrt add accounts-google
mrt add accounts-ui
# Add this into ANY template that you want the login buttons to appear
{{> loginButtons}}
angular.module('clientApp')
.controller('LoginCtrl', function($scope, $routeParams, User, $location, AppAuth) {
$scope.registration = {};
$scope.credentials = {};
$scope.login = function() {
$scope.loginResult = User.login({include: 'user', rememberMe: true}, $scope.credentials,
function() {
var next = $location.nextAfterLogin || '/';
$location.nextAfterLogin = null;
AppAuth.currentUser = $scope.loginResult.user;
$location.path(next);
$scope.currentUser = AppAuth.currentUser;
},
function(res) {
$scope.loginError = res.data.error;
}
);
};
$scope.register = function() {
$scope.user = User.save($scope.registration,
function() {
// successful!
$location.path('/login');
},
function(res) {
$scope.registerError = res.data.error;
}
);
};
});
angular.module('clientApp')
.factory('AppAuth', function() {
return {
currentUser: null,
// Note: we can't make the User a dependency of AppAuth
// because that would create a circular dependency
// AppAuth <- $http <- $resource <- LoopBackResource <- User <- AppAuth
ensureHasCurrentUser: function(User) {
if (!this.currentUser) {
this.currentUser = User.getCurrent(function(user){
return user;
}, function(err){
return null;
});
}
}
};
});
angular.module('clientApp')
.controller('NavCtrl', function ($scope, User, $location, AppAuth) {
AppAuth.ensureHasCurrentUser(User);
$scope.currentUser = AppAuth.currentUser;
$scope.$watch(function() {
return AppAuth.currentUser;
}, function(newValue) {
$scope.currentUser = newValue;
});
$scope.options = [
{text: 'Logout', action: function() {
User.logout(function() {
$scope.currentUser =
AppAuth.currentUser = null;
$location.path('/');
});
}}
];
});
mrt add package-name-here
I’d say that Meteor is actually quite stable — although it doesn’t have the 1.0 moniker yet, it’s pretty close and certainly isn’t an immature project.
- Tom from Percolate Studios
We have more than a dozen apps in production right now, and are not experiencing any stability issues.
-Developers at Differential.io