Fix pre-commit script to properly handle multiple files and resolve ESLint warnings
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { dbService } from '../../services/couchdb.factory';
|
||||
import { AccountStatus } from './auth.constants';
|
||||
import { User } from '../../types';
|
||||
import { AuthenticatedUser } from './auth.types';
|
||||
import { EmailVerificationService } from './emailVerification.service';
|
||||
|
||||
@@ -33,17 +31,17 @@ const authService = {
|
||||
},
|
||||
|
||||
async login(input: { email: string; password: string }) {
|
||||
console.log('🔐 Login attempt for:', input.email);
|
||||
console.warn('🔐 Login attempt for:', input.email);
|
||||
|
||||
// Find user by email
|
||||
const user = await dbService.findUserByEmail(input.email);
|
||||
|
||||
if (!user) {
|
||||
console.log('❌ User not found for email:', input.email);
|
||||
console.warn('❌ User not found for email:', input.email);
|
||||
throw new Error('User not found');
|
||||
}
|
||||
|
||||
console.log('👤 User found:', {
|
||||
console.warn('👤 User found:', {
|
||||
email: user.email,
|
||||
hasPassword: !!user.password,
|
||||
role: user.role,
|
||||
@@ -53,25 +51,25 @@ const authService = {
|
||||
|
||||
// Check if user has a password (email-based account)
|
||||
if (!user.password) {
|
||||
console.log('❌ No password found - OAuth account');
|
||||
console.warn('❌ No password found - OAuth account');
|
||||
throw new Error(
|
||||
'This account was created with OAuth. Please use Google or GitHub to sign in.'
|
||||
);
|
||||
}
|
||||
|
||||
// Simple password verification (in production, use bcrypt)
|
||||
console.log('🔍 Comparing passwords:', {
|
||||
console.warn('🔍 Comparing passwords:', {
|
||||
inputPassword: input.password,
|
||||
storedPassword: user.password,
|
||||
match: user.password === input.password,
|
||||
});
|
||||
|
||||
if (user.password !== input.password) {
|
||||
console.log('❌ Password mismatch');
|
||||
console.warn('❌ Password mismatch');
|
||||
throw new Error('Invalid password');
|
||||
}
|
||||
|
||||
console.log('✅ Login successful for:', user.email);
|
||||
console.warn('✅ Login successful for:', user.email);
|
||||
|
||||
// Return mock tokens for frontend compatibility
|
||||
return {
|
||||
@@ -204,7 +202,10 @@ const authService = {
|
||||
const resetTokens = JSON.parse(
|
||||
localStorage.getItem('password_reset_tokens') || '[]'
|
||||
);
|
||||
const resetToken = resetTokens.find((t: any) => t.token === token);
|
||||
const resetToken = resetTokens.find(
|
||||
(t: { token: string; userId: string; email: string; expiresAt: Date }) =>
|
||||
t.token === token
|
||||
);
|
||||
|
||||
if (!resetToken) {
|
||||
throw new Error('Invalid or expired reset token');
|
||||
@@ -227,7 +228,10 @@ const authService = {
|
||||
);
|
||||
|
||||
// Remove used token
|
||||
const filteredTokens = resetTokens.filter((t: any) => t.token !== token);
|
||||
const filteredTokens = resetTokens.filter(
|
||||
(t: { token: string; userId: string; email: string; expiresAt: Date }) =>
|
||||
t.token !== token
|
||||
);
|
||||
localStorage.setItem(
|
||||
'password_reset_tokens',
|
||||
JSON.stringify(filteredTokens)
|
||||
|
||||
Reference in New Issue
Block a user