Skip to content

Commit

Permalink
Merge pull request #1 from TEDx-SJEC/auth
Browse files Browse the repository at this point in the history
Auth
  • Loading branch information
joywin2003 authored Sep 10, 2024
2 parents 3301ae4 + ddce14c commit 9010897
Show file tree
Hide file tree
Showing 19 changed files with 410 additions and 93 deletions.
12 changes: 0 additions & 12 deletions .env

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel


# typescript
*.tsbuildinfo
next-env.d.ts
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@libsql/client": "^0.8.1",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/adapter-libsql": "^5.19.1",
"@prisma/client": "^5.19.1",
"next": "14.2.6",
Expand Down
Binary file modified prisma/dev.db
Binary file not shown.
Binary file modified prisma/dev.db-journal
Binary file not shown.
73 changes: 73 additions & 0 deletions prisma/migrations/20240910061511_re/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Warnings:
- You are about to drop the column `access_token` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `expires_at` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `id_token` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `provider` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `refresh_token` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `scope` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `session_state` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `token_type` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `type` on the `Account` table. All the data in the column will be lost.
- Added the required column `providerId` to the `Account` table without a default value. This is not possible if the table is not empty.
- Added the required column `providerType` to the `Account` table without a default value. This is not possible if the table is not empty.
- Added the required column `accessToken` to the `Session` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "User" ADD COLUMN "image" TEXT;

-- CreateTable
CREATE TABLE "VerificationRequest" (
"id" TEXT NOT NULL PRIMARY KEY,
"identifier" TEXT NOT NULL,
"token" TEXT NOT NULL,
"expires" DATETIME NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Account" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL,
"providerType" TEXT NOT NULL,
"providerId" TEXT NOT NULL,
"providerAccountId" TEXT NOT NULL,
"refreshToken" TEXT,
"accessToken" TEXT,
"accessTokenExpires" DATETIME,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_Account" ("createdAt", "id", "providerAccountId", "updatedAt", "userId") SELECT "createdAt", "id", "providerAccountId", "updatedAt", "userId" FROM "Account";
DROP TABLE "Account";
ALTER TABLE "new_Account" RENAME TO "Account";
CREATE UNIQUE INDEX "Account_providerId_providerAccountId_key" ON "Account"("providerId", "providerAccountId");
CREATE TABLE "new_Session" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL,
"expires" DATETIME NOT NULL,
"sessionToken" TEXT NOT NULL,
"accessToken" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_Session" ("createdAt", "expires", "id", "sessionToken", "updatedAt", "userId") SELECT "createdAt", "expires", "id", "sessionToken", "updatedAt", "userId" FROM "Session";
DROP TABLE "Session";
ALTER TABLE "new_Session" RENAME TO "Session";
CREATE UNIQUE INDEX "Session_sessionToken_key" ON "Session"("sessionToken");
CREATE UNIQUE INDEX "Session_accessToken_key" ON "Session"("accessToken");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;

-- CreateIndex
CREATE UNIQUE INDEX "VerificationRequest_token_key" ON "VerificationRequest"("token");

-- CreateIndex
CREATE UNIQUE INDEX "VerificationRequest_identifier_token_key" ON "VerificationRequest"("identifier", "token");
112 changes: 112 additions & 0 deletions prisma/migrations/20240910062346_case/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
Warnings:
- You are about to drop the column `accessToken` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `accessTokenExpires` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `createdAt` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `providerAccountId` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `providerId` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `providerType` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `refreshToken` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `updatedAt` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `userId` on the `Account` table. All the data in the column will be lost.
- You are about to drop the column `createdAt` on the `Referral` table. All the data in the column will be lost.
- You are about to drop the column `accessToken` on the `Session` table. All the data in the column will be lost.
- You are about to drop the column `createdAt` on the `Session` table. All the data in the column will be lost.
- You are about to drop the column `sessionToken` on the `Session` table. All the data in the column will be lost.
- You are about to drop the column `updatedAt` on the `Session` table. All the data in the column will be lost.
- You are about to drop the column `createdAt` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `emailVerified` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `updatedAt` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `createdAt` on the `VerificationRequest` table. All the data in the column will be lost.
- You are about to drop the column `updatedAt` on the `VerificationRequest` table. All the data in the column will be lost.
- Added the required column `provider_account_id` to the `Account` table without a default value. This is not possible if the table is not empty.
- Added the required column `provider_id` to the `Account` table without a default value. This is not possible if the table is not empty.
- Added the required column `provider_type` to the `Account` table without a default value. This is not possible if the table is not empty.
- Added the required column `updated_at` to the `Account` table without a default value. This is not possible if the table is not empty.
- Added the required column `user_id` to the `Account` table without a default value. This is not possible if the table is not empty.
- Added the required column `access_token` to the `Session` table without a default value. This is not possible if the table is not empty.
- Added the required column `session_token` to the `Session` table without a default value. This is not possible if the table is not empty.
- Added the required column `updated_at` to the `Session` table without a default value. This is not possible if the table is not empty.
- Added the required column `updated_at` to the `User` table without a default value. This is not possible if the table is not empty.
- Added the required column `updated_at` to the `VerificationRequest` table without a default value. This is not possible if the table is not empty.
*/
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Account" (
"id" TEXT NOT NULL PRIMARY KEY,
"user_id" TEXT NOT NULL,
"provider_type" TEXT NOT NULL,
"provider_id" TEXT NOT NULL,
"provider_account_id" TEXT NOT NULL,
"refresh_token" TEXT,
"access_token" TEXT,
"access_token_expires" DATETIME,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL,
CONSTRAINT "Account_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_Account" ("id") SELECT "id" FROM "Account";
DROP TABLE "Account";
ALTER TABLE "new_Account" RENAME TO "Account";
CREATE UNIQUE INDEX "Account_provider_id_provider_account_id_key" ON "Account"("provider_id", "provider_account_id");
CREATE TABLE "new_Referral" (
"id" TEXT NOT NULL PRIMARY KEY,
"code" TEXT NOT NULL,
"createdby_id" TEXT NOT NULL,
"usedby_id" TEXT,
"isUsed" BOOLEAN NOT NULL DEFAULT false,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Referral_createdby_id_fkey" FOREIGN KEY ("createdby_id") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "Referral_usedby_id_fkey" FOREIGN KEY ("usedby_id") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Referral" ("code", "createdby_id", "id", "isUsed", "usedby_id") SELECT "code", "createdby_id", "id", "isUsed", "usedby_id" FROM "Referral";
DROP TABLE "Referral";
ALTER TABLE "new_Referral" RENAME TO "Referral";
CREATE UNIQUE INDEX "Referral_code_key" ON "Referral"("code");
CREATE TABLE "new_Session" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL,
"expires" DATETIME NOT NULL,
"session_token" TEXT NOT NULL,
"access_token" TEXT NOT NULL,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL,
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_Session" ("expires", "id", "userId") SELECT "expires", "id", "userId" FROM "Session";
DROP TABLE "Session";
ALTER TABLE "new_Session" RENAME TO "Session";
CREATE UNIQUE INDEX "Session_session_token_key" ON "Session"("session_token");
CREATE UNIQUE INDEX "Session_access_token_key" ON "Session"("access_token");
CREATE TABLE "new_User" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT,
"email" TEXT,
"email_verified" DATETIME,
"image" TEXT,
"role" TEXT NOT NULL DEFAULT 'PARTICIPANT',
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL
);
INSERT INTO "new_User" ("email", "id", "image", "name", "role") SELECT "email", "id", "image", "name", "role" FROM "User";
DROP TABLE "User";
ALTER TABLE "new_User" RENAME TO "User";
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
CREATE TABLE "new_VerificationRequest" (
"id" TEXT NOT NULL PRIMARY KEY,
"identifier" TEXT NOT NULL,
"token" TEXT NOT NULL,
"expires" DATETIME NOT NULL,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL
);
INSERT INTO "new_VerificationRequest" ("expires", "id", "identifier", "token") SELECT "expires", "id", "identifier", "token" FROM "VerificationRequest";
DROP TABLE "VerificationRequest";
ALTER TABLE "new_VerificationRequest" RENAME TO "VerificationRequest";
CREATE UNIQUE INDEX "VerificationRequest_token_key" ON "VerificationRequest"("token");
CREATE UNIQUE INDEX "VerificationRequest_identifier_token_key" ON "VerificationRequest"("identifier", "token");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
28 changes: 28 additions & 0 deletions prisma/migrations/20240910062624_map/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Warnings:
- You are about to drop the `Account` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropTable
PRAGMA foreign_keys=off;
DROP TABLE "Account";
PRAGMA foreign_keys=on;

-- CreateTable
CREATE TABLE "accounts" (
"id" TEXT NOT NULL PRIMARY KEY,
"user_id" TEXT NOT NULL,
"provider_type" TEXT NOT NULL,
"provider_id" TEXT NOT NULL,
"provider_account_id" TEXT NOT NULL,
"refresh_token" TEXT,
"access_token" TEXT,
"access_token_expires" DATETIME,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL,
CONSTRAINT "accounts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);

-- CreateIndex
CREATE UNIQUE INDEX "accounts_provider_id_provider_account_id_key" ON "accounts"("provider_id", "provider_account_id");
60 changes: 60 additions & 0 deletions prisma/migrations/20240910063008_acc/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Warnings:
- You are about to drop the `Session` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the column `access_token_expires` on the `accounts` table. All the data in the column will be lost.
- You are about to drop the column `provider_id` on the `accounts` table. All the data in the column will be lost.
- You are about to drop the column `provider_type` on the `accounts` table. All the data in the column will be lost.
- Added the required column `provider` to the `accounts` table without a default value. This is not possible if the table is not empty.
- Added the required column `type` to the `accounts` table without a default value. This is not possible if the table is not empty.
*/
-- DropIndex
DROP INDEX "Session_access_token_key";

-- DropIndex
DROP INDEX "Session_session_token_key";

-- DropTable
PRAGMA foreign_keys=off;
DROP TABLE "Session";
PRAGMA foreign_keys=on;

-- CreateTable
CREATE TABLE "sessions" (
"id" TEXT NOT NULL PRIMARY KEY,
"session_token" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"expires" DATETIME NOT NULL,
CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);

-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_accounts" (
"id" TEXT NOT NULL PRIMARY KEY,
"user_id" TEXT NOT NULL,
"type" TEXT NOT NULL,
"provider" TEXT NOT NULL,
"provider_account_id" TEXT NOT NULL,
"refresh_token" TEXT,
"access_token" TEXT,
"expires_at" INTEGER,
"token_type" TEXT,
"scope" TEXT,
"id_token" TEXT,
"session_state" TEXT,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" DATETIME NOT NULL,
CONSTRAINT "accounts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_accounts" ("access_token", "created_at", "id", "provider_account_id", "refresh_token", "updated_at", "user_id") SELECT "access_token", "created_at", "id", "provider_account_id", "refresh_token", "updated_at", "user_id" FROM "accounts";
DROP TABLE "accounts";
ALTER TABLE "new_accounts" RENAME TO "accounts";
CREATE UNIQUE INDEX "accounts_provider_provider_account_id_key" ON "accounts"("provider", "provider_account_id");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;

-- CreateIndex
CREATE UNIQUE INDEX "sessions_session_token_key" ON "sessions"("session_token");
Loading

0 comments on commit 9010897

Please sign in to comment.