-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): Make email for UM case insensitive (#3078)
* π§ lowercasing email * β add tests for case insensitive email * π add migration to lowercase email * π rename migration * π fix package.lock * π fix double import * π add todo
- Loading branch information
1 parent
d3fecb9
commit 8532b00
Showing
15 changed files
with
204 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/cli/src/databases/mysqldb/migrations/1648740597343-LowerCaseUserEmail.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import config = require('../../../../config'); | ||
|
||
export class LowerCaseUserEmail1648740597343 implements MigrationInterface { | ||
name = 'LowerCaseUserEmail1648740597343'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const tablePrefix = config.get('database.tablePrefix'); | ||
|
||
await queryRunner.query(` | ||
UPDATE ${tablePrefix}user | ||
SET email = LOWER(email); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/cli/src/databases/postgresdb/migrations/1648740597343-LowerCaseUserEmail.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import config = require('../../../../config'); | ||
|
||
export class LowerCaseUserEmail1648740597343 implements MigrationInterface { | ||
name = 'LowerCaseUserEmail1648740597343'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
let tablePrefix = config.get('database.tablePrefix'); | ||
const schema = config.get('database.postgresdb.schema'); | ||
if (schema) { | ||
tablePrefix = schema + '.' + tablePrefix; | ||
} | ||
|
||
await queryRunner.query(` | ||
UPDATE ${tablePrefix}user | ||
SET email = LOWER(email); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/cli/src/databases/sqlite/migrations/1648740597343-LowerCaseUserEmail.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import config = require('../../../../config'); | ||
import { logMigrationEnd, logMigrationStart } from '../../utils/migrationHelpers'; | ||
|
||
export class LowerCaseUserEmail1648740597343 implements MigrationInterface { | ||
name = 'LowerCaseUserEmail1648740597343'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
logMigrationStart(this.name); | ||
|
||
const tablePrefix = config.get('database.tablePrefix'); | ||
|
||
await queryRunner.query(` | ||
UPDATE "${tablePrefix}user" | ||
SET email = LOWER(email); | ||
`); | ||
|
||
logMigrationEnd(this.name); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.