From de0ed77a43c1597a8519abd31f017b528bba070e Mon Sep 17 00:00:00 2001 From: Roland Schlaefli Date: Wed, 7 Dec 2022 16:23:19 +0100 Subject: [PATCH] enhance: use azure ad and @db.Text --- .../20221207152228_text/migration.sql | 36 +++++++++++++++++++ prisma/schema.prisma | 7 ++-- src/lib/authOptions.ts | 12 +++---- 3 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 prisma/migrations/20221207152228_text/migration.sql diff --git a/prisma/migrations/20221207152228_text/migration.sql b/prisma/migrations/20221207152228_text/migration.sql new file mode 100644 index 0000000..fc45e08 --- /dev/null +++ b/prisma/migrations/20221207152228_text/migration.sql @@ -0,0 +1,36 @@ +/* + Warnings: + + - You are about to alter the column `description` on the `Proposal` table. The data in that column could be lost. The data in that column will be cast from `NVarChar(1000)` to `Text`. + - You are about to alter the column `motivation` on the `ProposalApplication` table. The data in that column could be lost. The data in that column will be cast from `NVarChar(1000)` to `Text`. + - You are about to alter the column `comment` on the `UserProposalFeedback` table. The data in that column could be lost. The data in that column will be cast from `NVarChar(1000)` to `Text`. + +*/ +BEGIN TRY + +BEGIN TRAN; + +-- AlterTable +ALTER TABLE [dbo].[Account] ADD [ext_expires_in] INT; + +-- AlterTable +ALTER TABLE [dbo].[Proposal] ALTER COLUMN [description] TEXT NOT NULL; + +-- AlterTable +ALTER TABLE [dbo].[ProposalApplication] ALTER COLUMN [motivation] TEXT NOT NULL; + +-- AlterTable +ALTER TABLE [dbo].[UserProposalFeedback] ALTER COLUMN [comment] TEXT NOT NULL; + +COMMIT TRAN; + +END TRY +BEGIN CATCH + +IF @@TRANCOUNT > 0 +BEGIN + ROLLBACK TRAN; +END; +THROW + +END CATCH diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 6bad628..c0b43ef 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -43,6 +43,7 @@ model Account { scope String? id_token String? @db.Text session_state String? + ext_expires_in Int? user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@ -118,7 +119,7 @@ model Proposal { id String @id @unique @default(uuid()) title String - description String + description String @db.Text language String studyLevel String timeFrame String? @@ -156,7 +157,7 @@ model ProposalApplication { matriculationNumber String fullName String plannedStartAt DateTime - motivation String + motivation String @db.Text attachments ApplicationAttachment[] @@ -200,7 +201,7 @@ model UserProposalFeedback { typeKey String reason String - comment String + comment String @db.Text @@unique([proposalId, userEmail]) } diff --git a/src/lib/authOptions.ts b/src/lib/authOptions.ts index a3fb39d..a67e960 100644 --- a/src/lib/authOptions.ts +++ b/src/lib/authOptions.ts @@ -1,7 +1,7 @@ import { PrismaAdapter } from '@next-auth/prisma-adapter' import type { NextAuthOptions } from 'next-auth' import { decode, encode } from 'next-auth/jwt' -// import AzureADProvider from 'next-auth/providers/azure-ad' +import AzureADProvider from 'next-auth/providers/azure-ad' import EmailProvider from 'next-auth/providers/email' import prisma from '../server/prisma' @@ -20,11 +20,11 @@ export const authOptions: NextAuthOptions = { }, from: process.env.EMAIL_FROM, }), - // AzureADProvider({ - // clientId: process.env.AZURE_AD_CLIENT_ID as string, - // clientSecret: process.env.AZURE_AD_CLIENT_SECRET as string, - // tenantId: process.env.AZURE_AD_TENANT_ID as string, - // }), + AzureADProvider({ + clientId: process.env.AZURE_AD_CLIENT_ID as string, + clientSecret: process.env.AZURE_AD_CLIENT_SECRET as string, + tenantId: process.env.AZURE_AD_TENANT_ID as string, + }), ], session: { strategy: 'jwt',