Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Template.userLogin.events({
- 'click .show-password': () => {
- let showPassword = $('.show-password');
- let passwordInput = $('.password-input');
- showPassword.removeClass('show-password ion-eye');
- showPassword.addClass('hide-password ion-eye-disabled');
- passwordInput.prop('type','text');
- },
- 'click .hide-password': () => {
- let hidePassword = $('.hide-password');
- let passwordInput = $('.password-input');
- hidePassword.removeClass('hide-password ion-eye-disabled');
- hidePassword.addClass('show-password ion-eye');
- passwordInput.prop('type','password');
- },
- 'click .button-login': () => {
- let username = $('#username').val();
- let password = $('#password').val();
- Meteor.loginWithPassword({username: username}, password, (error, result) => {
- if (error) {
- console.log('LOGIN FAILED - ' + error);
- toastService.showMessage("error", "Username or password is wrong !");
- } else {
- console.log("Login with username: " + username);
- let user = Meteor.users.findOne({ username: username })
- if (user) {
- console.log("User id: " + user["_id"]);
- Session.set("USER_ID", user["_id"]);
- }
- if (Meteor.isCordova) {
- Meteor.call('cordovaRegister', device.uuid, (err, data) => {
- if (data != '') {
- Router.go("/inpatient");
- } else {
- Router.go("/");
- }
- });
- } else {
- Router.go("/");
- }
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement