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());
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user