Returning a promise on logout and delegating login redireciton
This commit is contained in:
parent
0cfd02316f
commit
44fa8f0e21
@ -26,16 +26,8 @@ Template.userLogin.onCreated(() => {
|
||||
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
|
||||
return OHIF.user.login(formData).then(successHandler).catch(errorHandler);
|
||||
return OHIF.user.login(formData).catch(errorHandler);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
OHIF.user.logout = () => Meteor.logout(error => {
|
||||
if (error) {
|
||||
OHIF.ui.showDialog('dialogInfo', {
|
||||
title: 'Error',
|
||||
message: error.reason
|
||||
});
|
||||
}
|
||||
OHIF.user.logout = () => new Promise((resolve, reject) => {
|
||||
Meteor.logout(error => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user