Skip to content

Commit

Permalink
Step 18.41: Create Auth component
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Kisiela authored and Dotan Simha committed Nov 22, 2016
1 parent efb981b commit 3ad0e43
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions imports/ui/components/auth/auth.js
@@ -0,0 +1,41 @@
import angular from 'angular';
import angularMeteor from 'angular-meteor';

import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

import template from './auth.html';
import { name as DisplayNameFilter } from '../../filters/displayNameFilter';

const name = 'auth';

class Auth {
constructor($scope, $reactive) {
'ngInject';

$reactive(this).attach($scope);

this.helpers({
isLoggedIn() {
return !!Meteor.userId();
},
currentUser() {
return Meteor.user();
}
});
}

logout() {
Accounts.logout();
}
}

// create a module
export default angular.module(name, [
angularMeteor,
DisplayNameFilter
]).component(name, {
template,
controllerAs: name,
controller: Auth
});

0 comments on commit 3ad0e43

Please sign in to comment.