Making login work with Meteor Accounts package

This commit is contained in:
Bruno Alves de Faria 2017-03-23 19:01:22 -03:00
parent d47bcb9c2a
commit 65ee016efc
3 changed files with 25 additions and 4 deletions

View File

@ -33,8 +33,8 @@ OHIF.studylist.retrieveStudyMetadata = studyInstanceUid => {
Meteor.call('GetStudyMetadata', studyInstanceUid, function(error, study) {
console.timeEnd('retrieveStudyMetadata');
if (Meteor.user && Meteor.user()) {
HipaaLogger.logEvent({
if (window.HipaaLogger && Meteor.user && Meteor.user()) {
window.HipaaLogger.logEvent({
eventType: 'viewed',
userId: Meteor.userId(),
userName: Meteor.user().profile.fullName,

View File

@ -1,5 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { Router } from 'meteor/iron:router';
Template.userLogin.onCreated(() => {
const instance = Template.instance();
@ -14,7 +16,22 @@ Template.userLogin.onCreated(() => {
// Get the form data
const formData = form.value();
console.warn('>>>>Logged in!', formData);
// Call the Meteor's login method
Meteor.loginWithPassword(formData.username, formData.password, error => {
if (!error) {
const currentRoute = Router.current();
const redirect = currentRoute.params.query.redirect;
const path = redirect ? decodeURI(redirect) : '/';
return Router.go(path);
}
const { reason } = error;
const isPassword = reason && reason.toLowerCase().indexOf('password') > -1;
const displayComponent = form.item(isPassword ? 'password' : 'username');
displayComponent.error(reason);
displayComponent.$element.focus();
});
}
};

View File

@ -8,7 +8,10 @@ Package.onUse(function(api) {
api.versionsFrom('1.4');
// Meteor client and server packages
api.use('ecmascript');
api.use([
'ecmascript',
'accounts-base'
]);
// Meteor client-only packages
api.use([
@ -21,5 +24,6 @@ Package.onUse(function(api) {
api.use('ohif:design');
api.use('ohif:core');
// Client imports
api.addFiles('client/index.js', 'client');
});