"use client"; import React, { useState, useEffect } from "react"; import { Text, Button, TextInput, PasswordInput, Title, Card, Box, Image } from "@mantine/core"; import { notifications } from "@mantine/notifications"; import { Providers } from "@/app/providers"; import { useRouter } from "next/navigation"; import NextImage from "next/image"; import logo from '@/app/image/logo.jpg'; import changePwdImage from '@/app/image/changepw.png'; // import CaptchaImage from './CaptchaImage'; import { IconEye, IconEyeOff, IconLock, IconLogout } from '@tabler/icons-react'; export default function ForgetLoginPwd() { const router = useRouter(); const [authorized, SetAuthorized] = useState(null); const [captcha, setCaptcha] = useState(""); const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const [captchaInput, setCaptchaInput] = useState(''); const [captchaError, setCaptchaError] = useState(''); const [confirmVisible, setConfirmVisible] = useState(false); const toggleConfirmVisibility = () => setConfirmVisible((v) => !v); const icon = ; async function handleLogout(e: React.FormEvent) { e.preventDefault(); localStorage.removeItem("access_token"); router.push("/login") } useEffect(() => { generateCaptcha(); }, []); const generateCaptcha = () => { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let result = ''; for (let i = 0; i < 6; i++) { result += chars.charAt(Math.floor(Math.random() * chars.length)); } setCaptcha(result); setCaptchaInput(''); setCaptchaError(''); }; async function handleSetLoginPassword(e: React.FormEvent) { e.preventDefault(); const pwdRegex = /^(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/; if (!password || !confirmPassword) { notifications.show({ withBorder: true, color: "red", title: "Both password fields are required.", message: "Both password fields are required.", autoClose: 5000, }); return; // alert("Both password fields are required."); } else if (password !== confirmPassword) { // alert("Passwords do not match."); notifications.show({ withBorder: true, color: "red", title: "Passwords do not match.", message: "Passwords do not match.", autoClose: 5000, }); return; } else if (!pwdRegex.test(password)) { // alert("Password must contain at least 1 capital letter, 1 number, 1 special character, and be at least 8 characters long."); notifications.show({ withBorder: true, color: "red", title: "Password must contain at least 1 capital letter, 1 number, 1 special character, and be at least 8 characters long.", message: "Password must contain at least 1 capital letter, 1 number, 1 special character, and be at least 8 characters long.", autoClose: 5000, }); return; } else if (captchaInput !== captcha) { setCaptchaError("Incorrect CAPTCHA."); return; } const token = localStorage.getItem("access_token"); const response = await fetch('api/auth/login_password', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ login_password: password, }), }); const data = await response.json(); if (response.ok) { console.log(data); notifications.show({ withBorder: true, color: "green", title: "Login Password has been set", message: "Login Password has been set", autoClose: 5000, }); router.push("/SetTxn"); } else { notifications.show({ withBorder: true, color: "red", title: "Please try again later ", message: "Please try again later ", autoClose: 5000, }); router.push("/login"); } } useEffect(() => { const token = localStorage.getItem("access_token"); if (!token) { SetAuthorized(false); router.push("/login"); } else { SetAuthorized(true); } }, []); if (authorized) { return (
ebanking
Change Password Image Set Login Password
setPassword(e.currentTarget.value)} onCopy={(e) => e.preventDefault()} onPaste={(e) => e.preventDefault()} onCut={(e) => e.preventDefault()} /> setConfirmPassword(e.currentTarget.value)} type={confirmVisible ? 'text' : 'password'} // rightSection={ // // } onCopy={(e) => e.preventDefault()} onPaste={(e) => e.preventDefault()} onCut={(e) => e.preventDefault()} /> {/* CAPTCHA */}
{/* */}
setCaptchaInput(e.currentTarget.value)} required /> {captchaError &&

{captchaError}

}


Note: Password will contains minimum one alphabet, one digit, one special symbol and total 8 charecters.
© 2025 Kangra Central Co-Operative Bank
); } }