Skip to content

Commit

Permalink
Step 21.6: Refactor login.js
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 8ae9c7e commit ff7ebb6
Showing 1 changed file with 8 additions and 34 deletions.
42 changes: 8 additions & 34 deletions imports/ui/components/login/login.js
Expand Up @@ -4,40 +4,14 @@ 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');
}
})
);
}
}
import webTemplate from './web.html';
import { Login as LoginWeb } from './web';
import mobileTemplate from './mobile.html';
import { Login as LoginMobile } from './mobile';

const name = 'login';
const template = Meteor.isCordova ? mobileTemplate : webTemplate;
const controller = Meteor.isCordova ? LoginMobile : LoginWeb;

// create a module
export default angular.module(name, [
Expand All @@ -46,8 +20,8 @@ export default angular.module(name, [
])
.component(name, {
template,
controllerAs: name,
controller: Login
controller,
controllerAs: name
})
.config(config);

Expand Down

0 comments on commit ff7ebb6

Please sign in to comment.