Skip to content

Commit

Permalink
fix: force lowercase for email on local auth
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Sep 9, 2020
1 parent 5295e41 commit aa96e97
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions server/db/migrations-sqlite/2.5.128.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.up = async knex => {
await knex('users').update({
email: knex.raw('LOWER(email)')
})
}

exports.down = knex => { }
7 changes: 7 additions & 0 deletions server/db/migrations/2.5.128.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.up = async knex => {
await knex('users').update({
email: knex.raw('LOWER(??)', ['email'])
})
}

exports.down = knex => { }
2 changes: 1 addition & 1 deletion server/models/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion server/modules/authentication/local/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit aa96e97

Please sign in to comment.