From b2bed61e82ee30c8b5e981b3d88a971f7da02a19 Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Wed, 30 Jun 2021 21:24:20 +0200 Subject: [PATCH] Working --- database/migrations/1625078903131_users.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/database/migrations/1625078903131_users.ts b/database/migrations/1625078903131_users.ts index c4beb14..02db217 100644 --- a/database/migrations/1625078903131_users.ts +++ b/database/migrations/1625078903131_users.ts @@ -5,11 +5,11 @@ export default class Users extends BaseSchema { protected tableName = 'users' public async up () { - this.schema.createTable(this.tableName, async (table) => { + this.schema.createTable(this.tableName, (table) => { table.increments('id').primary() table.string('username', 255).notNullable() table.string('email', 255).notNullable() - table.string('password', 180).defaultTo(await this.randomPassword()).notNullable() + table.string('password', 180).defaultTo(this.randomPassword()).notNullable() table.boolean('is_confirmed').defaultTo(false).notNullable() table.string('remember_me_token').defaultTo(null).nullable() table.string('confirmation_token').defaultTo(null).nullable() @@ -17,14 +17,16 @@ export default class Users extends BaseSchema { }) } - private async randomPassword(): Promise { + private randomPassword(): string { let password = '' const char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!.:=+-_$*^&@#%ù/àçè()é"' const size = 64 for (let i = 0; i < size; i++) { password += char.charAt(Math.random() * char.length) } - password = await Hash.make(password) + Hash.make(password).then((value => { + password = value + })) return password }