Add admin CLI command and auth guard, use oRPC client
CLI changes: - Use official oRPC client instead of manual HTTP requests - Add admin complete-login command for dev workflow - Remove type assertions, use proper ContractRouterClient typing - Add @orpc/client and @orpc/contract dependencies API changes: - Use oRPC cookie helpers from @orpc/server/helpers - Improve admin complete-login error messages (expired, already completed) Dashboard changes: - Add AuthGuard component to redirect unauthenticated users to /auth/login - Update confirm page with correct CLI command and copy button - Remove duplicate auth redirect from dashboard layout Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,39 +4,11 @@ import { createApiClient } from "../../utils/api-client.js";
|
||||
import { getConfigPath, readConfig } from "../../utils/config.js";
|
||||
import { TOKEN_PREFIX } from "../../utils/token.js";
|
||||
|
||||
interface AuthStatusResponse {
|
||||
user: {
|
||||
id: number;
|
||||
email: string;
|
||||
displayName: string | null;
|
||||
fullName: string | null;
|
||||
isSuperuser: boolean;
|
||||
emailVerified: boolean;
|
||||
};
|
||||
auth:
|
||||
| {
|
||||
method: "api_token";
|
||||
tokenId: string;
|
||||
tokenName: string;
|
||||
expiresAt: string;
|
||||
lastUsedAt: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
| {
|
||||
method: "session";
|
||||
sessionId: string;
|
||||
expiresAt: string;
|
||||
createdAt: string;
|
||||
};
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string): string {
|
||||
const date = new Date(dateStr);
|
||||
function formatDate(date: Date): string {
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
function formatRelativeTime(dateStr: string): string {
|
||||
const date = new Date(dateStr);
|
||||
function formatRelativeTime(date: Date): string {
|
||||
const now = new Date();
|
||||
const diffMs = date.getTime() - now.getTime();
|
||||
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
||||
@@ -86,8 +58,8 @@ async function status(this: LocalContext): Promise<void> {
|
||||
// Try to fetch status from API
|
||||
console.log("\nAPI Status:");
|
||||
try {
|
||||
const client = await createApiClient();
|
||||
const response = await client.call<AuthStatusResponse>("me.authStatus");
|
||||
const api = await createApiClient();
|
||||
const response = await api.me.authStatus();
|
||||
|
||||
// User info
|
||||
console.log("\n User:");
|
||||
|
||||
Reference in New Issue
Block a user