@inertiapixel/nextjs-auth
Version:
Authentication system for Next.js. Supports credentials and social login, JWT token management, and lifecycle hooks — designed to integrate with nodejs-auth for full-stack MERN apps.
18 lines (17 loc) • 528 B
JavaScript
// src/login/otpLogin.ts
import { ApiClient } from '../apiClient';
import { parseToken } from '../tokenUtils';
const api = new ApiClient();
export const loginWithOTP = async (url, payload) => {
const data = await api.post(url, payload);
if (!data.accessToken) {
throw new Error('Access token missing in response');
}
const user = parseToken(data.accessToken);
return {
isAuthenticated: true,
accessToken: data.accessToken,
message: data.message ?? '',
user,
};
};