Add MVP version

This commit is contained in:
KMKoushik
2024-03-24 17:43:56 +11:00
parent 9032efa9b2
commit bbc64b5392
49 changed files with 3249 additions and 298 deletions

View File

@@ -5,7 +5,7 @@ import {
type NextAuthOptions,
} from "next-auth";
import { type Adapter } from "next-auth/adapters";
import DiscordProvider from "next-auth/providers/discord";
import GitHubProvider from "next-auth/providers/github";
import { env } from "~/env";
import { db } from "~/server/db";
@@ -19,16 +19,15 @@ import { db } from "~/server/db";
declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
id: number;
// ...other properties
// role: UserRole;
} & DefaultSession["user"];
}
// interface User {
// // ...other properties
// // role: UserRole;
// }
interface User {
id: number;
}
}
/**
@@ -57,6 +56,10 @@ export const authOptions: NextAuthOptions = {
*
* @see https://next-auth.js.org/providers/github
*/
GitHubProvider({
clientId: env.GITHUB_ID,
clientSecret: env.GITHUB_SECRET,
}),
],
};
@@ -66,3 +69,15 @@ export const authOptions: NextAuthOptions = {
* @see https://next-auth.js.org/configuration/nextjs
*/
export const getServerAuthSession = () => getServerSession(authOptions);
import { createHash } from "crypto";
/**
* Hashes a token using SHA-256.
*
* @param {string} token - The token to be hashed.
* @returns {string} The hashed token.
*/
export function hashToken(token: string) {
return createHash("sha256").update(token).digest("hex");
}