mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-02-01 20:37:49 +01:00
Working
This commit is contained in:
@@ -7,7 +7,7 @@ export default class Subscribers extends BaseSchema {
|
|||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('email').notNullable()
|
table.string('email').notNullable()
|
||||||
table.timestamps(true)
|
table.timestamps()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default class Pictures extends BaseSchema {
|
|||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('label').notNullable()
|
table.string('label').notNullable()
|
||||||
table.string('file_name').notNullable()
|
table.string('file_name').notNullable()
|
||||||
table.timestamps(true)
|
table.timestamps()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default class Posts extends BaseSchema {
|
|||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('slug').notNullable()
|
table.string('slug').notNullable()
|
||||||
table.integer('likes').notNullable()
|
table.integer('likes').notNullable()
|
||||||
table.timestamps(true)
|
table.timestamps()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default class Locations extends BaseSchema {
|
|||||||
table.string('place')
|
table.string('place')
|
||||||
table.string('left')
|
table.string('left')
|
||||||
table.date('since')
|
table.date('since')
|
||||||
table.timestamps(true)
|
table.timestamps()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default class Projects extends BaseSchema {
|
|||||||
table.string('description')
|
table.string('description')
|
||||||
table.string('url')
|
table.string('url')
|
||||||
table.integer('progress')
|
table.integer('progress')
|
||||||
table.timestamps(true)
|
table.timestamps()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default class Forms extends BaseSchema {
|
|||||||
table.string('email')
|
table.string('email')
|
||||||
table.string('subject')
|
table.string('subject')
|
||||||
table.string('content')
|
table.string('content')
|
||||||
table.timestamps(true)
|
table.timestamps()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default class GoldenMessages extends BaseSchema {
|
|||||||
table.increments('id')
|
table.increments('id')
|
||||||
table.integer('user_id').notNullable()
|
table.integer('user_id').notNullable()
|
||||||
table.string('message')
|
table.string('message')
|
||||||
table.timestamps(true)
|
table.timestamps()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
|
||||||
|
import Hash from "@ioc:Adonis/Core/Hash";
|
||||||
|
|
||||||
export default class Users extends BaseSchema {
|
export default class Users extends BaseSchema {
|
||||||
protected tableName = 'users'
|
protected tableName = 'users'
|
||||||
@@ -8,14 +9,26 @@ export default class Users extends BaseSchema {
|
|||||||
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).notNullable()
|
table.string('password', 180).defaultTo(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()
|
||||||
table.timestamps(true)
|
table.timestamps()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
console.log(password)
|
||||||
|
console.log(Hash.make(password))
|
||||||
|
return password
|
||||||
|
}
|
||||||
|
|
||||||
public async down () {
|
public async down () {
|
||||||
this.schema.dropTable(this.tableName)
|
this.schema.dropTable(this.tableName)
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ export default class ApiTokens extends BaseSchema {
|
|||||||
table.string('type').notNullable()
|
table.string('type').notNullable()
|
||||||
table.string('token', 64).notNullable()
|
table.string('token', 64).notNullable()
|
||||||
table.timestamp('expires_at', { useTz: true }).nullable()
|
table.timestamp('expires_at', { useTz: true }).nullable()
|
||||||
table.timestamp('created_at', { useTz: true }).notNullable()
|
table.timestamps()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user