Skip to content

Commit

Permalink
Step 18.43: Create Login
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 e84c593 commit d0db482
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions imports/ui/components/login/login.js
@@ -0,0 +1,61 @@
import angular from 'angular';
import angularMeteor from 'angular-meteor';
import uiRouter from 'angular-ui-router';

import { Meteor } from 'meteor/meteor';

import template from './login.html';

import { name as Register } from '../register/register';

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

this.$state = $state;

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

this.credentials = {
email: '',
password: ''
};

this.error = '';
}

login() {
Meteor.loginWithPassword(this.credentials.email, this.credentials.password,
this.$bindToContext((err) => {
if (err) {
this.error = err;
} else {
this.$state.go('parties');
}
})
);
}
}

const name = 'login';

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

function config($stateProvider) {
'ngInject';

$stateProvider.state('login', {
url: '/login',
template: '<login></login>'
});
}

0 comments on commit d0db482

Please sign in to comment.