mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Implement authentication
This commit is contained in:
parent
cdcd71cf2a
commit
3e4551ea7a
23 changed files with 656 additions and 406 deletions
23
prisma/migrations/20241120013541_fix_forgors/migration.sql
Normal file
23
prisma/migrations/20241120013541_fix_forgors/migration.sql
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE `config` MODIFY `createdAt` DATETIME(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
MODIFY `updatedAt` DATETIME(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `forgors` MODIFY `createdAt` DATETIME(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
MODIFY `updatedAt` DATETIME(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `users` MODIFY `createdAt` DATETIME(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
|
||||
MODIFY `updatedAt` DATETIME(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `Session` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`username` VARCHAR(255) NOT NULL,
|
||||
`expiresAt` DATETIME(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Session` ADD CONSTRAINT `Session_id_fkey` FOREIGN KEY (`id`) REFERENCES `users`(`username`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
10
prisma/migrations/20241120032217_sessions_2/migration.sql
Normal file
10
prisma/migrations/20241120032217_sessions_2/migration.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `username` on the `Session` table. All the data in the column will be lost.
|
||||
- Added the required column `userId` to the `Session` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `Session` DROP COLUMN `username`,
|
||||
ADD COLUMN `userId` VARCHAR(255) NOT NULL;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
-- DropForeignKey
|
||||
ALTER TABLE `Session` DROP FOREIGN KEY `Session_id_fkey`;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Session` ADD CONSTRAINT `Session_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`username`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (i.e. Git)
|
||||
provider = "mysql"
|
||||
|
|
@ -149,8 +149,8 @@ model User_Role {
|
|||
updatedAt DateTime @db.DateTime(0)
|
||||
userUsername String @db.VarChar(255)
|
||||
roleName String @db.VarChar(255)
|
||||
users users @relation(fields: [userUsername], references: [username], onDelete: Cascade, map: "User_Role_ibfk_1")
|
||||
roles roles @relation(fields: [roleName], references: [name], onDelete: Cascade, map: "User_Role_ibfk_2")
|
||||
user users @relation(fields: [userUsername], references: [username], onDelete: Cascade, map: "User_Role_ibfk_1")
|
||||
role roles @relation(fields: [roleName], references: [name], onDelete: Cascade, map: "User_Role_ibfk_2")
|
||||
|
||||
@@id([userUsername, roleName])
|
||||
@@index([roleName], map: "roleName")
|
||||
|
|
@ -317,7 +317,7 @@ model favorites {
|
|||
|
||||
model forgors {
|
||||
id Int @id @default(autoincrement())
|
||||
expires DateTime? @default(dbgenerated("DATE_ADD(NOW(), INTERVAL 24 HOUR)")) @db.DateTime(0)
|
||||
expires DateTime? @db.DateTime(0)
|
||||
key String? @db.VarChar(255)
|
||||
createdAt DateTime @default(now()) @db.DateTime(0)
|
||||
updatedAt DateTime @default(now()) @db.DateTime(0)
|
||||
|
|
@ -519,7 +519,7 @@ model users {
|
|||
updatedAt DateTime @default(now()) @db.DateTime(0)
|
||||
placeholder String? @db.Text
|
||||
imgId String? @db.VarChar(255)
|
||||
User_Role User_Role[]
|
||||
roles User_Role[]
|
||||
albumHistories albumHistories[]
|
||||
comments comments[]
|
||||
favorites favorites[]
|
||||
|
|
@ -527,4 +527,13 @@ model users {
|
|||
logs logs[]
|
||||
ratings ratings[]
|
||||
submissions submissions[]
|
||||
sessions Session[]
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id
|
||||
userId String @db.VarChar(255)
|
||||
expiresAt DateTime
|
||||
|
||||
user users @relation(references: [username], fields: [userId], onDelete: Cascade)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue