diff --git a/imports/ui/components/auth/auth.js b/imports/ui/components/auth/auth.js new file mode 100644 index 000000000..faffdb322 --- /dev/null +++ b/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 +});