Commit 5e8fcfdb by GD-A-150752

profile-avatar

parent 43b54281
/* tslint:disable:no-require-imports */
// tslint:disable-next-line:import-name
import S3 from 'aws-sdk/clients/s3';
import s3 from 'aws-sdk/clients/s3';
import { FilesCollection } from 'meteor/ostrio:files';
import '../env';
......@@ -10,9 +9,7 @@ let s3Conf;
let sendToStorage;
let interceptDownload;
let fileDir = './';
const bound = Meteor.bindEnvironment((callback) => {
return callback();
});
const bound = Meteor.bindEnvironment(callback => callback());
if (Meteor.isServer) {
const fs = require('fs');
......@@ -22,7 +19,7 @@ if (Meteor.isServer) {
fileDir = os.tmpdir();
s3Conf = JSON.parse(process.env.S3);
s3Client = new S3({
s3Client = new s3({
secretAccessKey: s3Conf.secret,
accessKeyId: s3Conf.key,
region: s3Conf.region,
......@@ -45,11 +42,14 @@ if (Meteor.isServer) {
(error) => {
bound(() => {
if (error) {
// console.error(error);
// tslint:disable-next-line:no-console
console.error(error);
} else {
files.update({ _id: fileRef._id }, { $set: { uploadedToS3: true } });
filesCollection.update({ _id: fileRef._id }, { $set: { uploadedToS3: true } });
if (fs.existsSync(fileRef.path)) {
fs.unlink(fileRef.path);
fs.unlink(fileRef.path, () => {
// file deleted.
});
}
}
});
......@@ -86,7 +86,8 @@ if (Meteor.isServer) {
s3Client.getObject(opts, (error, data) => {
if (error) {
// console.error(error);
// tslint:disable-next-line:no-console
console.error(error);
if (!http.response.finished) {
http.response.end();
}
......@@ -125,7 +126,7 @@ const onAfterUpload = (fileRef) => {
}
};
export const files = new FilesCollection({
export const filesCollection = new FilesCollection({
onBeforeUpload,
onAfterUpload,
interceptDownload,
......@@ -135,7 +136,7 @@ export const files = new FilesCollection({
});
if (Meteor.isServer) {
files.denyClient();
filesCollection.denyClient();
}
if (Meteor.isClient) {
......@@ -143,5 +144,5 @@ if (Meteor.isClient) {
}
if (Meteor.isServer) {
Meteor.publish('files.images.all', () => files.collection.find({}));
Meteor.publish('files.images.all', () => filesCollection.collection.find({}));
}
......@@ -12,11 +12,4 @@ Meteor.startup(() => {
return user && user.profile.role
&& UtilsService.hasPermissionOfUser(user, PERMISSIONS.CAN_LOGIN);
});
// Changing url of reset password
Accounts.emailTemplates.resetPassword.text = (user, url) => {
const token = url.substring(url.lastIndexOf('/') + 1, url.length);
return Meteor.absoluteUrl(`auth/reset-password/${token}`);
};
});
......@@ -7,14 +7,8 @@ Meteor.methods({
updateSettings(setting: any): void {
if (UtilsService.hasPermission(PERMISSIONS.CAN_UPDATE_SETTINGS)) {
settingsCollection.update(setting.id, {
$set: {
Value: {
SUBJECT: setting.subject,
CONTENT: setting.content,
},
},
});
Object.keys(setting)
.forEach(key => settingsCollection.update({ Key: key }, { $set: { Value: setting[key] } }));
} else {
throw new Meteor.Error(403, 'Not Enough Permissions');
}
......
......@@ -2,19 +2,10 @@ import { Meteor } from 'meteor/meteor';
import { rolesCollection } from '../collections/role.collection';
import { PERMISSIONS } from '../config';
import { UtilsService } from '../services/utils.service';
import { QueryModel } from '../models/query.model';
import { EmailService } from '../services/email.service';
Meteor.methods({
usersGetCount(query: QueryModel): any {
return {
recordsFiltered: Meteor.users.find(query.query).count(),
recordsTotal: Meteor.users.find().count(),
};
},
registerUser(user: any): string {
const defaultRole = rolesCollection.findOne({ title: user.role });
if (!Accounts.findUserByEmail(user.email)) {
......@@ -52,9 +43,6 @@ Meteor.methods({
}
if (user._id) {
if (user.password) {
Accounts.setPassword(user._id, user.password);
}
const updateObj = { $set: { profile: user.profile } };
return Meteor.users.update(user._id, updateObj);
......
import { CONFIG } from '../config';
import { settingsCollection } from '../collections/setting.collections';
import { rolesCollection } from "../collections/role.collection";
import { rolesCollection } from '../collections/role.collection';
export class EmailService {
static sendVerificationEmail(user: any, userId: string, email = false): void {
......@@ -24,7 +24,6 @@ export class EmailService {
},
};
const mail = email ? email : user.emails[0].address;
console.log(mail, userId);
Accounts.sendVerificationEmail(userId, mail);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment