Skip to content

Commit

Permalink
feat: goggle login with session and cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
axyut committed Dec 17, 2024
1 parent 533859b commit 5760fee
Show file tree
Hide file tree
Showing 26 changed files with 1,563 additions and 70 deletions.
1 change: 1 addition & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ PASSWORD=admin
ENVIRONMENT=development
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
ADMINS=aoogleak@gmail.com,boscofficial2021@gmail.com
API_DOMAIN=http://localhost:8787
WEB_DOMAIN=http://localhost:4321
15 changes: 15 additions & 0 deletions migrations/0007_short_chronomancer.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE `oauth_account` (
`provider` text NOT NULL,
`provider_user_id` text NOT NULL,
`user_id` text NOT NULL,
PRIMARY KEY(`provider`, `provider_user_id`),
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `oauth_account_provider_user_id_unique` ON `oauth_account` (`provider_user_id`);--> statement-breakpoint
CREATE TABLE `session` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`expires_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
1 change: 1 addition & 0 deletions migrations/0008_melted_preak.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `user` ADD `googleId` text;
25 changes: 25 additions & 0 deletions migrations/0009_eager_colossus.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_oauth_account` (
`provider` text NOT NULL,
`provider_user_id` text NOT NULL,
`user_id` integer NOT NULL,
PRIMARY KEY(`provider`, `provider_user_id`),
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
INSERT INTO `__new_oauth_account`("provider", "provider_user_id", "user_id") SELECT "provider", "provider_user_id", "user_id" FROM `oauth_account`;--> statement-breakpoint
DROP TABLE `oauth_account`;--> statement-breakpoint
ALTER TABLE `__new_oauth_account` RENAME TO `oauth_account`;--> statement-breakpoint
PRAGMA foreign_keys=ON;--> statement-breakpoint
CREATE UNIQUE INDEX `oauth_account_provider_user_id_unique` ON `oauth_account` (`provider_user_id`);--> statement-breakpoint
CREATE TABLE `__new_session` (
`id` text PRIMARY KEY NOT NULL,
`user_id` integer NOT NULL,
`expires_at` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
INSERT INTO `__new_session`("id", "user_id", "expires_at") SELECT "id", "user_id", "expires_at" FROM `session`;--> statement-breakpoint
DROP TABLE `session`;--> statement-breakpoint
ALTER TABLE `__new_session` RENAME TO `session`;--> statement-breakpoint
ALTER TABLE `user` DROP COLUMN `googleId`;
208 changes: 208 additions & 0 deletions migrations/meta/0007_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
{
"version": "6",
"dialect": "sqlite",
"id": "95858942-3ca8-4c65-8f68-7d5b0e71e844",
"prevId": "cbf49183-c7d6-4f90-ad76-f2bf1b4230e6",
"tables": {
"oauth_account": {
"name": "oauth_account",
"columns": {
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_user_id": {
"name": "provider_user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"oauth_account_provider_user_id_unique": {
"name": "oauth_account_provider_user_id_unique",
"columns": [
"provider_user_id"
],
"isUnique": true
}
},
"foreignKeys": {
"oauth_account_user_id_user_id_fk": {
"name": "oauth_account_user_id_user_id_fk",
"tableFrom": "oauth_account",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"oauth_account_provider_provider_user_id_pk": {
"columns": [
"provider",
"provider_user_id"
],
"name": "oauth_account_provider_provider_user_id_pk"
}
},
"uniqueConstraints": {},
"checkConstraints": {}
},
"session": {
"name": "session",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_user_id_user_id_fk": {
"name": "session_user_id_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"username": {
"name": "username",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": false
},
"profilePictureUrl": {
"name": "profilePictureUrl",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"refreshToken": {
"name": "refreshToken",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'audience'"
},
"createdAt": {
"name": "createdAt",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
Loading

0 comments on commit 5760fee

Please sign in to comment.