/
auth.js
47 lines (39 loc) · 970 Bytes
/
auth.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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';
import { name as Login } from '../login/login';
import { name as Register } from '../register/register';
import { name as Password } from '../password/password';
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,
Login,
Register,
Password
]).component(name, {
template,
controllerAs: name,
controller: Auth
});