universal_authentication
Version:
Seamless and Secure Authentication for Modern Web Applications: Easily integrate OTP-based email verification, Google OAuth, GitHub, Microsoft, and Okta login into your Node.js app. Modular, flexible, and database-agnostic, this package simplifies user au
21 lines (18 loc) • 598 B
text/typescript
import { verifyOtp } from "./otpStore.service";
// OTP Verification Handler Function
export const verifyOtpHandler = async (
email: string,
otp: string
): Promise<{ status: number; message: string }> => {
try {
// Verify OTP after successful login attempt
const isOtpValid = verifyOtp(email, otp);
if (!isOtpValid) {
return { status: 401, message: "Invalid or expired OTP" };
}
return { status: 200, message: "OTP verified successfully" };
} catch (err: any) {
console.error(err);
return { status: 500, message: err.message };
}
};