mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-21 23:40:26 +01:00
Working
This commit is contained in:
@@ -5,11 +5,11 @@ export default class Users extends BaseSchema {
|
|||||||
protected tableName = 'users'
|
protected tableName = 'users'
|
||||||
|
|
||||||
public async up () {
|
public async up () {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, async (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('username', 255).notNullable()
|
table.string('username', 255).notNullable()
|
||||||
table.string('email', 255).notNullable()
|
table.string('email', 255).notNullable()
|
||||||
table.string('password', 180).defaultTo(this.randomPassword()).notNullable()
|
table.string('password', 180).defaultTo(await this.randomPassword()).notNullable()
|
||||||
table.boolean('is_confirmed').defaultTo(false).notNullable()
|
table.boolean('is_confirmed').defaultTo(false).notNullable()
|
||||||
table.string('remember_me_token').defaultTo(null).nullable()
|
table.string('remember_me_token').defaultTo(null).nullable()
|
||||||
table.string('confirmation_token').defaultTo(null).nullable()
|
table.string('confirmation_token').defaultTo(null).nullable()
|
||||||
@@ -17,15 +17,14 @@ export default class Users extends BaseSchema {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private randomPassword (): string {
|
private async randomPassword(): Promise<string> {
|
||||||
let password = ''
|
let password = ''
|
||||||
const char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!.:=+-_$*^&@#%ù/àçè()é"'
|
const char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!.:=+-_$*^&@#%ù/àçè()é"'
|
||||||
const size = 64
|
const size = 64
|
||||||
for (let i = 0; i < size; i++) {
|
for (let i = 0; i < size; i++) {
|
||||||
password += char.charAt(Math.random() * char.length)
|
password += char.charAt(Math.random() * char.length)
|
||||||
}
|
}
|
||||||
console.log(password)
|
password = await Hash.make(password)
|
||||||
console.log(Hash.make(password))
|
|
||||||
return password
|
return password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user