init
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { IOauth1Token } from "garmin-connect/dist/garmin/types";
|
||||
import { getDb } from "@/lib/db";
|
||||
import { encrypt, decrypt } from "@/lib/crypto";
|
||||
import type { GarminPendingMfa } from "@/lib/garmin/sso";
|
||||
|
||||
const AUTH_COLLECTION = "garmin_auth";
|
||||
@@ -49,7 +50,7 @@ export async function getGarminCredentials(
|
||||
.collection<GarminCredentialsDoc>(CREDENTIALS_COLLECTION)
|
||||
.findOne({ _id: userId });
|
||||
if (!doc) return null;
|
||||
return { email: doc.email, password: doc.password };
|
||||
return { email: doc.email, password: decrypt(doc.password) };
|
||||
}
|
||||
|
||||
export async function saveGarminCredentials(
|
||||
@@ -60,5 +61,5 @@ export async function saveGarminCredentials(
|
||||
const db = await getDb();
|
||||
await db
|
||||
.collection<GarminCredentialsDoc>(CREDENTIALS_COLLECTION)
|
||||
.updateOne({ _id: userId }, { $set: { email, password } }, { upsert: true });
|
||||
.updateOne({ _id: userId }, { $set: { email, password: encrypt(password) } }, { upsert: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user