diff --git a/README.md b/README.md index 04459b0..145d7e6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Canopy -0.1-Alpha +0.1-Alpha (Panama Red) - Hotfix 1 ========= Canopy - /ˈkæ.nə.pi/: diff --git a/package.json b/package.json index e5e493e..8554c13 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "canopy-of-alpha", - "version": "0.1", - "canopyDisplayVersion": "0.1-Alpha", + "version": "0.1.1", + "canopyDisplayVersion": "0.1-Alpha (Panama Red) - Hotfix 1", "license": "AGPL-3.0-only", "dependencies": { "@braintree/sanitize-url": "^7.1.1", diff --git a/src/controllers/api/account/emailChangeRequestController.js b/src/controllers/api/account/emailChangeRequestController.js index 4791ba2..3108ab6 100644 --- a/src/controllers/api/account/emailChangeRequestController.js +++ b/src/controllers/api/account/emailChangeRequestController.js @@ -60,7 +60,7 @@ module.exports.post = async function(req, res){ //Look through DB and migration cache for existing email - const existingDB = await userModel.findOne({email: new RegExp(email, 'i')}); + const existingDB = await userModel.findOne({email: new RegExp(`^${email}$`, 'i')}); const needsMigration = userModel.migrationCache.emails.includes(email.toLowerCase()); //If the email is in use diff --git a/src/controllers/api/account/loginController.js b/src/controllers/api/account/loginController.js index d509342..be8685b 100644 --- a/src/controllers/api/account/loginController.js +++ b/src/controllers/api/account/loginController.js @@ -90,7 +90,7 @@ module.exports.post = async function(req, res){ const {user, pass} = matchedData(req); //Look for the username in the migration DB - const migrationDB = await migrationModel.findOne({user}); + const migrationDB = await migrationModel.findOne({user: new RegExp(`^${user}$`, 'i')}); //If we found a migration profile if(migrationDB != null){ diff --git a/src/schemas/user/migrationSchema.js b/src/schemas/user/migrationSchema.js index 9aff595..4e61ce0 100644 --- a/src/schemas/user/migrationSchema.js +++ b/src/schemas/user/migrationSchema.js @@ -323,7 +323,7 @@ migrationSchema.statics.buildMigrationCache = async function(){ migrationSchema.statics.consumeByUsername = async function(ip, migration){ //Pull migration doc by case-insensitive username - const migrationDB = await this.findOne({user: new RegExp(migration.user, 'i')}); + const migrationDB = await this.findOne({user: new RegExp(`^${migration.user}$`, 'i')}); //If we have no migration document if(migrationDB == null){ diff --git a/src/schemas/user/userSchema.js b/src/schemas/user/userSchema.js index 41dfcda..783b241 100644 --- a/src/schemas/user/userSchema.js +++ b/src/schemas/user/userSchema.js @@ -256,13 +256,13 @@ userSchema.statics.register = async function(userObj, ip){ //Check password confirmation matches if(pass == passConfirm){ //Setup user query - let userQuery = {user: new RegExp(user, 'i')}; + let userQuery = {user: new RegExp(`^${user}$`, 'i')}; //If we have an email if(email != null && email != ""){ userQuery = {$or: [ userQuery, - {email: new RegExp(email, 'i')} + {email: new RegExp(`^${email}$`, 'i')} ]}; } @@ -319,7 +319,7 @@ userSchema.statics.authenticate = async function(user, pass, failLine = "Bad Use } //get the user if it exists - const userDB = await this.findOne({ user: new RegExp(user, 'i')}); + const userDB = await this.findOne({ user: new RegExp(`^${user}$`, 'i')}); //if not scream and shout if(!userDB){