Moving user functions to ohif:user package
This commit is contained in:
parent
b7d1e91848
commit
d2289f5eb0
@ -3,6 +3,5 @@ import './cornerstone.js';
|
|||||||
import './object.js';
|
import './object.js';
|
||||||
import './string.js';
|
import './string.js';
|
||||||
import './ui.js';
|
import './ui.js';
|
||||||
import './user.js';
|
|
||||||
import './utils.js';
|
import './utils.js';
|
||||||
import './viewer.js';
|
import './viewer.js';
|
||||||
|
|||||||
@ -1,2 +1 @@
|
|||||||
import './mongo.js';
|
import './mongo.js';
|
||||||
import './user.js';
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
OHIF.user = {};
|
|
||||||
|
|
||||||
// Throw error if there is no user logged in
|
// Throw error if there is no user logged in
|
||||||
OHIF.user.validate = () => {
|
OHIF.user.validate = () => {
|
||||||
if (!Meteor.userId()) {
|
if (!Meteor.userId()) {
|
||||||
@ -31,5 +30,5 @@ OHIF.user.setData = (key, value) => {
|
|||||||
OHIF.user.validate();
|
OHIF.user.validate();
|
||||||
|
|
||||||
// Call the update method on server-side
|
// Call the update method on server-side
|
||||||
Meteor.call('userDataSet', key, value);
|
Meteor.call('ohif.user.data.set', key, value);
|
||||||
};
|
};
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
import './data';
|
||||||
import './getName';
|
import './getName';
|
||||||
import './login';
|
import './login';
|
||||||
import './logout';
|
import './logout';
|
||||||
|
|||||||
@ -28,6 +28,9 @@ Package.onUse(function(api) {
|
|||||||
// Main module
|
// Main module
|
||||||
api.mainModule('main.js', ['client', 'server']);
|
api.mainModule('main.js', ['client', 'server']);
|
||||||
|
|
||||||
|
// Server imports
|
||||||
|
api.addFiles('server/index.js', 'server');
|
||||||
|
|
||||||
// Client imports
|
// Client imports
|
||||||
api.addFiles('client/index.js', 'client');
|
api.addFiles('client/index.js', 'client');
|
||||||
});
|
});
|
||||||
|
|||||||
1
Packages/ohif-user/server/index.js
Normal file
1
Packages/ohif-user/server/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
import './user.js';
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import { OHIF } from 'meteor/ohif:core';
|
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
|
import { Accounts } from 'meteor/accounts-base';
|
||||||
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
// Manipulate user's persistent data
|
// Manipulate user's persistent data
|
||||||
class UserData {
|
class UserData {
|
||||||
@ -24,19 +25,13 @@ class UserData {
|
|||||||
OHIF.MongoUtils.validateUser();
|
OHIF.MongoUtils.validateUser();
|
||||||
|
|
||||||
// Build the query to update only the current user's data
|
// Build the query to update only the current user's data
|
||||||
var query = {
|
const query = { _id: Meteor.userId() };
|
||||||
_id: Meteor.userId()
|
|
||||||
};
|
|
||||||
|
|
||||||
// Build the path to the persistent data with the given key
|
// Build the path to the persistent data with the given key
|
||||||
const persistentPath = `profile.persistent.${key}`;
|
const persistentPath = `profile.persistent.${key}`;
|
||||||
|
|
||||||
// Build the data to be updated
|
// Build the data to be updated
|
||||||
var data = {
|
const data = { $set: { [persistentPath]: value } };
|
||||||
$set: {
|
|
||||||
[persistentPath]: value
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Update the user's profile data with the persistent information
|
// Update the user's profile data with the persistent information
|
||||||
Accounts.users.update(query, data, OHIF.MongoUtils.writeCallback);
|
Accounts.users.update(query, data, OHIF.MongoUtils.writeCallback);
|
||||||
@ -46,9 +41,6 @@ class UserData {
|
|||||||
|
|
||||||
// Register the methods
|
// Register the methods
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
userDataGet: key => UserData.get(key),
|
'ohif.user.data.get': key => UserData.get(key),
|
||||||
userDataSet: (key, value) => UserData.set(key, value)
|
'ohif.user.data.set': (key, value) => UserData.set(key, value)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Expose the class in the OHIF object
|
|
||||||
OHIF.UserData = UserData;
|
|
||||||
Loading…
Reference in New Issue
Block a user