Users ObjectId migration
This commit is contained in:
parent
4227389a67
commit
fc56bd3273
7 changed files with 72 additions and 91 deletions
|
|
@ -5,18 +5,11 @@ import SimpleSchema from 'simpl-schema';
|
||||||
import { defaultCreatedAt, defaultUpdateAt } from '/imports/api/Utility/Utils.js';
|
import { defaultCreatedAt, defaultUpdateAt } from '/imports/api/Utility/Utils.js';
|
||||||
|
|
||||||
const schemaUserProfile = new SimpleSchema({
|
const schemaUserProfile = new SimpleSchema({
|
||||||
/* Our users has a name of type Object while Google Service, for instance, not */
|
/* Our users has a name of type Object while Google Service, for instance, String, so blackbox in true in profile */
|
||||||
/* name: { type: String, optional: true }, */
|
/* name: { type: String, optional: true }, */
|
||||||
/* name: Object,
|
name: { type: Object, optional: true },
|
||||||
'name.first': String,
|
'name.first': String,
|
||||||
'name.last': String, */
|
'name.last': String
|
||||||
lang: { type: String, optional: true },
|
|
||||||
telegramChatId: { type: Number, optional: true },
|
|
||||||
telegramUsername: { type: String, optional: true },
|
|
||||||
telegramFirstName: { type: String, optional: true },
|
|
||||||
telegramLanguageCode: { type: String, optional: true },
|
|
||||||
createdAt: defaultCreatedAt,
|
|
||||||
updatedAt: defaultUpdateAt
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const schemaUser = new SimpleSchema({
|
const schemaUser = new SimpleSchema({
|
||||||
|
|
@ -59,11 +52,6 @@ const schemaUser = new SimpleSchema({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
optional: true // if not present === notVerified
|
optional: true // if not present === notVerified
|
||||||
},
|
},
|
||||||
profile: {
|
|
||||||
type: schemaUserProfile,
|
|
||||||
// i18nLabel: 'Otros datos',
|
|
||||||
optional: true
|
|
||||||
},
|
|
||||||
// Make sure this services field is in your schema
|
// Make sure this services field is in your schema
|
||||||
// if you're using any of the accounts packages
|
// if you're using any of the accounts packages
|
||||||
services: {
|
services: {
|
||||||
|
|
@ -103,7 +91,26 @@ const schemaUser = new SimpleSchema({
|
||||||
slug: {
|
slug: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true
|
optional: true
|
||||||
}
|
},
|
||||||
|
profile: {
|
||||||
|
type: schemaUserProfile,
|
||||||
|
optional: true,
|
||||||
|
blackbox: true
|
||||||
|
},
|
||||||
|
// https://guide.meteor.com/accounts.html#custom-user-data
|
||||||
|
|
||||||
|
/* Our users has a name of type Object while Google Service, for instance, not */
|
||||||
|
/* name: { type: String, optional: true }, */
|
||||||
|
/* name: Object,
|
||||||
|
'name.first': String,
|
||||||
|
'name.last': String, */
|
||||||
|
lang: { type: String, optional: true },
|
||||||
|
telegramChatId: { type: Number, optional: true },
|
||||||
|
telegramUsername: { type: String, optional: true },
|
||||||
|
telegramFirstName: { type: String, optional: true },
|
||||||
|
telegramLanguageCode: { type: String, optional: true },
|
||||||
|
createdAt: defaultCreatedAt,
|
||||||
|
updatedAt: defaultUpdateAt
|
||||||
});
|
});
|
||||||
|
|
||||||
Meteor.users.attachSchema(schemaUser);
|
Meteor.users.attachSchema(schemaUser);
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,4 @@ import './api';
|
||||||
import './fixtures';
|
import './fixtures';
|
||||||
import './email';
|
import './email';
|
||||||
import './IPGeocoder';
|
import './IPGeocoder';
|
||||||
|
import './migrations';
|
||||||
|
|
|
||||||
31
imports/startup/server/migrations.js
Normal file
31
imports/startup/server/migrations.js
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* global Migrations */
|
||||||
|
/* eslint-disable import/no-absolute-path */
|
||||||
|
import { Meteor } from 'meteor/meteor';
|
||||||
|
|
||||||
|
Meteor.startup(() => {
|
||||||
|
// https://github.com/percolatestudio/meteor-migrations
|
||||||
|
|
||||||
|
Migrations.config({
|
||||||
|
// Log job run details to console
|
||||||
|
log: true
|
||||||
|
});
|
||||||
|
|
||||||
|
Migrations.add({
|
||||||
|
version: 1,
|
||||||
|
up: function migrateIds() {
|
||||||
|
// https://docs.mongodb.com/manual/reference/operator/query/type/
|
||||||
|
Meteor.users.find({ _id: { $type: 7 } }).forEach((user) => {
|
||||||
|
const migratedUser = user;
|
||||||
|
const id = user._id.valueOf();
|
||||||
|
console.log(`Migrating id of user: ${JSON.stringify(user)}`);
|
||||||
|
Meteor.users.remove({ _id: user._id });
|
||||||
|
migratedUser._id = id;
|
||||||
|
Meteor.users.insert(migratedUser);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Migrations.migrateTo('latest');
|
||||||
|
|
||||||
|
// Migrations.migrateTo('1,rerun');
|
||||||
|
});
|
||||||
|
|
@ -16,7 +16,7 @@ class Login extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
this.t = props.t;
|
this.t = props.t;
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
console.log(this.props.location.state);
|
// console.log(this.props.location.state);
|
||||||
this.state = props.location.state;
|
this.state = props.location.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { Link } from 'react-router-dom';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { Accounts } from 'meteor/accounts-base';
|
import { Accounts } from 'meteor/accounts-base';
|
||||||
import { Bert } from 'meteor/themeteorchef:bert';
|
import { Bert } from 'meteor/themeteorchef:bert';
|
||||||
import randomHex from 'random-hexadecimal';
|
import randomHex from 'crypto-random-hex';
|
||||||
import Icon from '../../components/Icon/Icon';
|
import Icon from '../../components/Icon/Icon';
|
||||||
import OAuthLoginButtons from '../../components/OAuthLoginButtons/OAuthLoginButtons';
|
import OAuthLoginButtons from '../../components/OAuthLoginButtons/OAuthLoginButtons';
|
||||||
import InputHint from '../../components/InputHint/InputHint';
|
import InputHint from '../../components/InputHint/InputHint';
|
||||||
|
|
@ -86,7 +86,6 @@ class Signup extends React.Component {
|
||||||
Meteor.call('users.sendVerificationEmail');
|
Meteor.call('users.sendVerificationEmail');
|
||||||
Bert.alert(t('Bienvenid@!'), 'success');
|
Bert.alert(t('Bienvenid@!'), 'success');
|
||||||
history.push('/subscriptions');
|
history.push('/subscriptions');
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +101,7 @@ class Signup extends React.Component {
|
||||||
<button
|
<button
|
||||||
className="btn btn-block btn-raised btn-primary OAuthLoginButtonDis OAuthLoginButton-telegram"
|
className="btn btn-block btn-raised btn-primary OAuthLoginButtonDis OAuthLoginButton-telegram"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => { const hex = randomHex({ max: 20 }); window.open(`https://t.me/TodosContraElFuego_bot?start=${hex}`); }}
|
onClick={() => { const hex = randomHex(20); console.log(hex); window.open(`https://t.me/TodosContraElFuego_bot?start=${hex}`); }}
|
||||||
>
|
>
|
||||||
<span><Icon icon="telegram" /> {t('Iniciar sesión con Telegram')}</span>
|
<span><Icon icon="telegram" /> {t('Iniciar sesión con Telegram')}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
83
package-lock.json
generated
83
package-lock.json
generated
|
|
@ -257,6 +257,11 @@
|
||||||
"integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
|
"integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"array-buffer-to-hex": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/array-buffer-to-hex/-/array-buffer-to-hex-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-arycdkxgK1cj6s03GDb96tlCxOl1n3kg9M2OHseUc6Pqyqp+lgfceFPmG507eI5V+oxOSEnlOw/dFc7LXBXF4Q=="
|
||||||
|
},
|
||||||
"array-equal": {
|
"array-equal": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz",
|
||||||
|
|
@ -2342,11 +2347,6 @@
|
||||||
"integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==",
|
"integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"clamp": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/clamp/-/clamp-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-ZqDmQBGBbjcZaCj9yMjBRzEshjQ="
|
|
||||||
},
|
|
||||||
"classnames": {
|
"classnames": {
|
||||||
"version": "2.2.5",
|
"version": "2.2.5",
|
||||||
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.5.tgz",
|
||||||
|
|
@ -2846,6 +2846,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"crypto-random-hex": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/crypto-random-hex/-/crypto-random-hex-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-1DuZQ03El13TRgfrqbbjW40Gvi4OKInny/Wxqj23/JMXe214C/3Tlz92bKXWDW3NZT5RjXUGdYW4qiIOUPf+cA==",
|
||||||
|
"requires": {
|
||||||
|
"array-buffer-to-hex": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"css-animation": {
|
"css-animation": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/css-animation/-/css-animation-1.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/css-animation/-/css-animation-1.4.1.tgz",
|
||||||
|
|
@ -5255,11 +5263,6 @@
|
||||||
"number-is-nan": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz"
|
"number-is-nan": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is-function": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU="
|
|
||||||
},
|
|
||||||
"is-glob": {
|
"is-glob": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
|
||||||
|
|
@ -5280,11 +5283,6 @@
|
||||||
"xtend": "4.0.1"
|
"xtend": "4.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is-nil": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-nil/-/is-nil-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-LauingtYUGOHXntTnQcfWxWTeWk="
|
|
||||||
},
|
|
||||||
"is-number": {
|
"is-number": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz",
|
||||||
|
|
@ -5294,11 +5292,6 @@
|
||||||
"kind-of": "3.2.2"
|
"kind-of": "3.2.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is-object": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA="
|
|
||||||
},
|
|
||||||
"is-path-cwd": {
|
"is-path-cwd": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz",
|
||||||
|
|
@ -7635,11 +7628,6 @@
|
||||||
"tmpl": "1.0.4"
|
"tmpl": "1.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"max-safe-int": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/max-safe-int/-/max-safe-int-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-RPuo7Jk97ZH7LFo15xz5yfNpzlI="
|
|
||||||
},
|
|
||||||
"maxmind": {
|
"maxmind": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/maxmind/-/maxmind-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/maxmind/-/maxmind-2.3.0.tgz",
|
||||||
|
|
@ -9649,33 +9637,6 @@
|
||||||
"ret": "0.1.15"
|
"ret": "0.1.15"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"random-hexadecimal": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/random-hexadecimal/-/random-hexadecimal-1.0.3.tgz",
|
|
||||||
"integrity": "sha1-vg80y8Jbnz21I8NZpUarl//zz1c=",
|
|
||||||
"requires": {
|
|
||||||
"random-natural": "1.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"random-integral": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/random-integral/-/random-integral-1.0.3.tgz",
|
|
||||||
"integrity": "sha1-j/PBF1ZcmgS2bd1VnzrtKb0PD2w=",
|
|
||||||
"requires": {
|
|
||||||
"clamp": "1.0.1",
|
|
||||||
"max-safe-int": "1.0.0",
|
|
||||||
"to-integer": "1.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"random-natural": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/random-natural/-/random-natural-1.0.3.tgz",
|
|
||||||
"integrity": "sha1-7yhhWwPCy3Gq6/fyT0hyZqRDxcA=",
|
|
||||||
"requires": {
|
|
||||||
"max-safe-int": "1.0.0",
|
|
||||||
"random-integral": "1.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"randomatic": {
|
"randomatic": {
|
||||||
"version": "1.1.7",
|
"version": "1.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz",
|
||||||
|
|
@ -11353,24 +11314,6 @@
|
||||||
"integrity": "sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=",
|
"integrity": "sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"to-integer": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/to-integer/-/to-integer-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-URrUHc5qk3MKjztuNaFk/YKUZNo=",
|
|
||||||
"requires": {
|
|
||||||
"is-function": "1.0.1",
|
|
||||||
"is-nil": "1.0.1",
|
|
||||||
"is-object": "1.0.1",
|
|
||||||
"is-symbol": "1.0.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"is-symbol": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tough-cookie": {
|
"tough-cookie": {
|
||||||
"version": "2.3.3",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz",
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
"bcrypt": "^1.0.3",
|
"bcrypt": "^1.0.3",
|
||||||
"commonmark": "^0.28.1",
|
"commonmark": "^0.28.1",
|
||||||
"core-js": "^2.5.1",
|
"core-js": "^2.5.1",
|
||||||
|
"crypto-random-hex": "^1.0.0",
|
||||||
"fs": "0.0.1-security",
|
"fs": "0.0.1-security",
|
||||||
"google-maps": "^3.2.1",
|
"google-maps": "^3.2.1",
|
||||||
"handlebars": "^4.0.11",
|
"handlebars": "^4.0.11",
|
||||||
|
|
@ -42,7 +43,6 @@
|
||||||
"nodemailer": "^4.4.1",
|
"nodemailer": "^4.4.1",
|
||||||
"popper.js": "^1.12.7",
|
"popper.js": "^1.12.7",
|
||||||
"prop-types": "^15.6.0",
|
"prop-types": "^15.6.0",
|
||||||
"random-hexadecimal": "^1.0.3",
|
|
||||||
"rc-slider": "^8.5.0",
|
"rc-slider": "^8.5.0",
|
||||||
"rc-tooltip": "^3.7.0",
|
"rc-tooltip": "^3.7.0",
|
||||||
"react": "^16.0.0",
|
"react": "^16.0.0",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue