UNPKG

strapi-plugin-firebase-authentication

Version:

Allows easy integration between clients utilizing Firebase for authentication and Strapi

63 lines (62 loc) 2.62 kB
import { Context } from "koa"; declare const firebaseController: { validateToken(ctx: any): Promise<any>; deleteByEmail(email: any): Promise<any>; overrideAccess(ctx: any): Promise<any>; /** * Controller method for email/password authentication * Handles the `/api/firebase-authentication/emailLogin` endpoint * * @param ctx - Koa context object * @returns Promise that sets ctx.body with user data and JWT or error message * * @remarks * This controller acts as a proxy to Firebase's Identity Toolkit API, * allowing users to authenticate with email/password and receive a Strapi JWT. * * HTTP Status Codes: * - `400`: Validation errors (missing credentials, invalid email/password) * - `500`: Server errors (missing configuration, Firebase API issues) */ emailLogin(ctx: any): Promise<void>; /** * Forgot password - sends reset email * POST /api/firebase-authentication/forgotPassword * Public endpoint - no authentication required */ forgotPassword(ctx: any): Promise<void>; /** * Reset password - authenticated password change * POST /api/firebase-authentication/resetPassword * Authenticated endpoint - requires valid JWT (enforced by is-authenticated policy) * Used for admin-initiated resets or user self-service password changes * NOT used for forgot password email flow (which uses Firebase's hosted UI) */ resetPassword(ctx: any): Promise<void>; requestMagicLink(ctx: Context): Promise<void>; /** * Reset password using custom JWT token * POST /api/firebase-authentication/resetPasswordWithToken * Public endpoint - token provides authentication * * @param ctx - Koa context with { token, newPassword } in body * @returns { success: true, message: "Password has been reset successfully" } */ resetPasswordWithToken(ctx: Context): Promise<void>; /** * Send email verification - public endpoint * POST /api/firebase-authentication/sendVerificationEmail * Authenticated endpoint - sends verification email to the logged-in user's email */ sendVerificationEmail(ctx: Context): Promise<void>; /** * Verify email using custom JWT token * POST /api/firebase-authentication/verifyEmail * Public endpoint - token provides authentication * * @param ctx - Koa context with { token } in body * @returns { success: true, message: "Email verified successfully" } */ verifyEmail(ctx: Context): Promise<Context>; }; export default firebaseController;