This commit is contained in:
2026-02-03 20:29:55 +08:00
parent d5dde77ee9
commit 9d42a45bb1
18 changed files with 484 additions and 186 deletions

View File

@@ -5,19 +5,23 @@ import { headers } from "next/headers";
import { redirect } from "next/navigation";
import { ValidateError } from "@/lib/errors";
import {
ActionInputGetUserProfileByUsername,
ActionInputSignIn,
ActionInputSignUp,
ActionOutputAuth,
ActionOutputUserProfile,
validateActionInputGetUserProfileByUsername,
validateActionInputSignIn,
validateActionInputSignUp
} from "./auth-action-dto";
import {
serviceGetUserProfileByUsername,
serviceSignIn,
serviceSignUp
} from "./auth-service";
// Re-export types for use in components
export type { ActionOutputAuth } from "./auth-action-dto";
export type { ActionOutputAuth, ActionOutputUserProfile } from "./auth-action-dto";
/**
* Sign up action
@@ -144,3 +148,32 @@ export async function signOutAction() {
redirect("/auth");
}
}
/**
* Get user profile by username
* Returns user profile data for display
*/
export async function actionGetUserProfileByUsername(dto: ActionInputGetUserProfileByUsername): Promise<ActionOutputUserProfile> {
try {
const userProfile = await serviceGetUserProfileByUsername(dto);
if (!userProfile) {
return {
success: false,
message: "User not found",
};
}
return {
success: true,
message: "User profile retrieved successfully",
data: userProfile,
};
} catch (e) {
console.error("Get user profile error:", e);
return {
success: false,
message: "Failed to retrieve user profile",
};
}
}