Reimplemented outdated code, added encryption keys for each room, added support for profile images, added friend requests via url/qr-code
This commit is contained in:
1 parent
508f17315e
commit
32e4bf8b32
58 files changed
+3270
-362
No files matched your search
@@ -0,0 +1,35 @@
|
||||
"use server";
|
||||
|
||||
import { redirect } from "next/navigation";
|
||||
import { login } from "@/utils/authentication/signin";
|
||||
|
||||
export type LoginState = {
|
||||
error?: string;
|
||||
} | null;
|
||||
|
||||
export async function loginAction(
|
||||
_prevState: LoginState,
|
||||
formData: FormData,
|
||||
): Promise<LoginState> {
|
||||
const email = formData.get("email");
|
||||
const password = formData.get("password");
|
||||
const next = formData.get("next");
|
||||
|
||||
if (typeof email !== "string" || typeof password !== "string") {
|
||||
return { error: "Email and password are required." };
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await login(email, password);
|
||||
if (result?.error) {
|
||||
return { error: result.error.message ?? "Login failed." };
|
||||
}
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Login failed.";
|
||||
return { error: message };
|
||||
}
|
||||
|
||||
const redirectTo =
|
||||
typeof next === "string" && next.startsWith("/") ? next : "/profile";
|
||||
redirect(redirectTo);
|
||||
}
|
||||
Reference in new issue
Block a user