fix: force lowercase for email on local auth
This commit is contained in:
		
							
								
								
									
										7
									
								
								server/db/migrations-sqlite/2.5.128.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								server/db/migrations-sqlite/2.5.128.js
									
									
									
									
									
										Normal file
									
								
							@@ -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
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								server/db/migrations/2.5.128.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					exports.up = async knex => {
 | 
				
			||||||
 | 
					  await knex('users').update({
 | 
				
			||||||
 | 
					    email: knex.raw('LOWER(??)', ['email'])
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exports.down = knex => { }
 | 
				
			||||||
@@ -675,7 +675,7 @@ module.exports = class User extends Model {
 | 
				
			|||||||
        if (dupUsr) {
 | 
					        if (dupUsr) {
 | 
				
			||||||
          throw new WIKI.Error.AuthAccountAlreadyExists()
 | 
					          throw new WIKI.Error.AuthAccountAlreadyExists()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        usrData.email = email
 | 
					        usrData.email = _.toLower(email)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (!_.isEmpty(name) && name !== usr.name) {
 | 
					      if (!_.isEmpty(name) && name !== usr.name) {
 | 
				
			||||||
        usrData.name = _.trim(name)
 | 
					        usrData.name = _.trim(name)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ module.exports = {
 | 
				
			|||||||
      }, async (uEmail, uPassword, done) => {
 | 
					      }, async (uEmail, uPassword, done) => {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
          const user = await WIKI.models.users.query().findOne({
 | 
					          const user = await WIKI.models.users.query().findOne({
 | 
				
			||||||
            email: uEmail,
 | 
					            email: uEmail.toLowerCase(),
 | 
				
			||||||
            providerKey: 'local'
 | 
					            providerKey: 'local'
 | 
				
			||||||
          })
 | 
					          })
 | 
				
			||||||
          if (user) {
 | 
					          if (user) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user