Browse Source

fix: force lowercase for email on local auth

pull/2429/head
NGPixel 4 years ago
parent
commit
aa96e97028
4 changed files with 16 additions and 2 deletions
  1. 7
      server/db/migrations-sqlite/2.5.128.js
  2. 7
      server/db/migrations/2.5.128.js
  3. 2
      server/models/users.js
  4. 2
      server/modules/authentication/local/authentication.js

7
server/db/migrations-sqlite/2.5.128.js

@ -0,0 +1,7 @@
exports.up = async knex => {
await knex('users').update({
email: knex.raw('LOWER(email)')
})
}
exports.down = knex => { }

7
server/db/migrations/2.5.128.js

@ -0,0 +1,7 @@
exports.up = async knex => {
await knex('users').update({
email: knex.raw('LOWER(??)', ['email'])
})
}
exports.down = knex => { }

2
server/models/users.js

@ -675,7 +675,7 @@ module.exports = class User extends Model {
if (dupUsr) {
throw new WIKI.Error.AuthAccountAlreadyExists()
}
usrData.email = email
usrData.email = _.toLower(email)
}
if (!_.isEmpty(name) && name !== usr.name) {
usrData.name = _.trim(name)

2
server/modules/authentication/local/authentication.js

@ -15,7 +15,7 @@ module.exports = {
}, async (uEmail, uPassword, done) => {
try {
const user = await WIKI.models.users.query().findOne({
email: uEmail,
email: uEmail.toLowerCase(),
providerKey: 'local'
})
if (user) {

Loading…
Cancel
Save