Stop storing github access tokens for github authenticated users

This commit is contained in:
Eric Allam
2023-07-31 15:41:44 +01:00
parent fdf1b2148c
commit 3e5945fb9e
6 changed files with 21 additions and 12 deletions
+2 -8
View File
@@ -11,7 +11,6 @@ type FindOrCreateMagicLink = {
type FindOrCreateGithub = {
authenticationMethod: "GITHUB";
email: User["email"];
accessToken: User["accessToken"];
authenticationProfile: GitHubProfile;
authenticationExtraParams: Record<string, unknown>;
};
@@ -61,7 +60,6 @@ export async function findOrCreateMagicLinkUser(
export async function findOrCreateGithubUser({
email,
accessToken,
authenticationProfile,
authenticationExtraParams,
}: FindOrCreateGithub): Promise<LoggedInUser> {
@@ -98,7 +96,6 @@ export async function findOrCreateGithubUser({
email,
},
data: {
accessToken,
authenticationProfile: authProfile,
authenticationExtraParams: authExtraParams,
avatarUrl,
@@ -117,9 +114,7 @@ export async function findOrCreateGithubUser({
where: {
id: existingUser.id,
},
data: {
accessToken,
},
data: {},
});
return {
@@ -132,9 +127,8 @@ export async function findOrCreateGithubUser({
where: {
authIdentifier,
},
update: { accessToken },
update: {},
create: {
accessToken,
authenticationProfile: authProfile,
authenticationExtraParams: authExtraParams,
name,
@@ -17,7 +17,7 @@ export function addGitHubStrategy(
clientSecret,
callbackURL: `${env.LOGIN_ORIGIN}/auth/github/callback`,
},
async ({ accessToken, extraParams, profile }) => {
async ({ extraParams, profile }) => {
const emails = profile.emails;
if (!emails) {
@@ -34,7 +34,6 @@ export function addGitHubStrategy(
const { user, isNewUser } = await findOrCreateUser({
email: emails[0].value,
authenticationMethod: "GITHUB",
accessToken,
authenticationProfile: profile,
authenticationExtraParams: extraParams,
});
+1
View File
@@ -10,6 +10,7 @@
"scripts": {
"build": "turbo run build",
"build:force": "turbo run build --force",
"build:db:seed": "turbo run build:db:seed",
"db:migrate": "turbo run db:migrate:deploy generate",
"db:seed": "turbo run db:seed",
"db:studio": "turbo run db:studio",
@@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `accessToken` on the `User` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "User" DROP COLUMN "accessToken";
-1
View File
@@ -13,7 +13,6 @@ model User {
email String @unique
authenticationMethod AuthenticationMethod
accessToken String?
authenticationProfile Json?
authenticationExtraParams Json?
authIdentifier String? @unique
+9 -1
View File
@@ -13,6 +13,11 @@
".cache"
]
},
"build:db:seed": {
"outputs": [
"prisma/seed.js"
]
},
"webapp#start": {
"dependsOn": [
"^build"
@@ -36,7 +41,10 @@
"cache": false
},
"db:seed": {
"cache": false
"cache": false,
"dependsOn": [
"build:db:seed"
]
},
"db:studio": {
"cache": false