Skip to content

Commit

Permalink
fix(lib/actions): MongoDB connection timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ad956 committed Aug 10, 2024
1 parent a2f97e2 commit 9c33bfd
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion app/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import getBaseUrl from "@utils/getBaseUrl";
import getModelByRole from "@utils/getModelByRole";
import logDemoUser from "./demo-user/logDemoUser";
import DemoUser from "@models/demouser";
import { dbConfig } from "@/utils";

export async function loginAction(formData: FormData) {
const email = formData.get("email");
Expand All @@ -32,7 +33,29 @@ export async function loginAction(formData: FormData) {

export async function demoLoginAction(role: string) {
try {
const demoUser = await DemoUser.findOne({ role });
/******************************************************
* *
* ___ _____ *
* / /\ / /::\ *
* / /::\ / /:/\:\ *
* / /:/\:\ / /:/ \:\ *
* / /:/~/::\ /__/:/ \__\:| *
* /__/:/ /:/\:\ \ \:\ / /:/ *
* \ \:\/:/__\/ \ \:\ /:/ *
* \ \::/ \ \:\/:/ *
* \ \:\ \ \::/ *
* \ \:\ \__\/ *
* \__\/ *
* *
* Note to self: Databases don't configure themselves *
* Pro tip: Always dbConfig() before you wreck yo'self*
* *
******************************************************/
await dbConfig();

const demoUser = await DemoUser.findOne({
role,
});

if (!demoUser) {
return { success: false, error: "Demo user not found for this role" };
Expand Down

0 comments on commit 9c33bfd

Please sign in to comment.