Desktop oAuth integration
Co-authored-by: RagingLightning <RagingLightningCode@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"use server";
|
||||
import { generateUUID } from "../../../../helper/uuid";
|
||||
import { getServerSession } from "../../../api/auth/[...nextauth]/auth";
|
||||
import { Service } from "../page";
|
||||
import { PrismaClient } from "@repo/db";
|
||||
@@ -9,15 +10,7 @@ export const generateToken = async (service: Service) => {
|
||||
const session = await getServerSession();
|
||||
if (!session) return null;
|
||||
|
||||
const key = await crypto.subtle.generateKey(
|
||||
{ name: "HMAC", hash: "SHA-256" },
|
||||
true,
|
||||
["sign"],
|
||||
);
|
||||
const exportedKey = await crypto.subtle.exportKey("raw", key);
|
||||
const accessToken = Array.from(new Uint8Array(exportedKey))
|
||||
.map((byte) => byte.toString(16).padStart(2, "0"))
|
||||
.join("");
|
||||
const accessToken = generateUUID(16);
|
||||
|
||||
const code = await prisma.oAuthToken.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user