Files
cozsweet-frontend-nextjs/src/lib/auth/auth_platform.ts
T
admin 6e51cb7d16 Refactor: Remove original Dart references from comments across multiple files
- Updated comments in various components, schemas, and repositories to remove references to original Dart files.
- Ensured consistency in documentation while maintaining the context of the code.
2026-06-29 11:31:21 +08:00

33 lines
932 B
TypeScript

"use client";
/**
* AuthPlatform 统一 OAuth 登录入口
*
* 两个独立方法(不再依赖构造器):
* - `googleSignIn()` → 触发 Google OAuth
* - `facebookSignIn()` → 触发 Facebook OAuth
*
* NextAuth 流程:
* 1. NextAuth 重定向到 provider OAuth 授权页
* 2. 用户授权 → 回调 /api/auth/callback/{provider}
* 3. NextAuth 写 next-auth.session-token (httpOnly) cookie
* 4. 重定向到 callbackUrl (默认 /chat)
*
* 不做任何持久化(不写 unstorage / 不调后端 / 不设自定义 cookie)。
*
*/
import { signIn } from "next-auth/react";
export type AuthProvider = "facebook" | "google";
export class AuthPlatform {
/** 触发 Google OAuth 跳转 */
static async googleSignIn(): Promise<void> {
await signIn("google");
}
/** 触发 Facebook OAuth 跳转 */
static async facebookSignIn(): Promise<void> {
await signIn("facebook");
}
}