Returning a promise on logout and delegating login redireciton

This commit is contained in:
Bruno Alves de Faria 2017-09-27 14:10:10 -03:00
parent 0cfd02316f
commit 44fa8f0e21
2 changed files with 9 additions and 16 deletions

View File

@ -26,16 +26,8 @@ Template.userLogin.onCreated(() => {
Meteor.defer(() => displayComponent.$element.focus()); Meteor.defer(() => displayComponent.$element.focus());
}; };
// Handle success and redirect the user
const successHandler = () => {
const currentRoute = Router.current();
const redirect = currentRoute.params.query.redirect;
const path = redirect ? decodeURI(redirect) : '/';
return Router.go(path);
};
// Call the login method // Call the login method
return OHIF.user.login(formData).then(successHandler).catch(errorHandler); return OHIF.user.login(formData).catch(errorHandler);
} }
}; };

View File

@ -1,11 +1,12 @@
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { OHIF } from 'meteor/ohif:core'; import { OHIF } from 'meteor/ohif:core';
OHIF.user.logout = () => Meteor.logout(error => { OHIF.user.logout = () => new Promise((resolve, reject) => {
if (error) { Meteor.logout(error => {
OHIF.ui.showDialog('dialogInfo', { if (error) {
title: 'Error', reject(error);
message: error.reason }
});
} resolve();
});
}); });