Skip to content

Commit

Permalink
backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Capta1nRaj committed Feb 5, 2024
1 parent 1872347 commit 6789d2f
Show file tree
Hide file tree
Showing 14 changed files with 239 additions and 403 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "next/core-web-vitals"
}
"extends": ["next/core-web-vitals"],
"rules": {
"@next/next/no-img-element": "off"
}
}
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"axios": "^1.6.5",
"bcrypt": "^5.1.1",
"connect2mongodb": "^1.0.7",
"email-armor": "^0.0.82-beta.0",
"email-armor": "^0.0.83-beta.0",
"mongoose": "^8.0.1",
"next": "14.0.3",
"react": "^18",
Expand Down
35 changes: 0 additions & 35 deletions src/app/api/forgotPassword/route.js

This file was deleted.

19 changes: 0 additions & 19 deletions src/app/api/logout/route.js

This file was deleted.

51 changes: 0 additions & 51 deletions src/app/api/resend/route.js

This file was deleted.

34 changes: 0 additions & 34 deletions src/app/api/sessionCheck/route.js

This file was deleted.

34 changes: 0 additions & 34 deletions src/app/api/signUp/route.js

This file was deleted.

23 changes: 23 additions & 0 deletions src/app/api/signUpAPI/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { NextResponse } from "next/server";
import { signup } from 'email-armor'
import { cookies } from 'next/headers'

console.clear();

export async function POST(request) {

const { userFullName, userName, userEmail, userPassword, userReferredBy, userAgent, userIP } = await request.json();

const signUpUser = await signup(userFullName, userName, userEmail, userPassword, userReferredBy, userAgent, userIP);

// cookies().set('id', signInUser.id);
// cookies().set('userName', signInUser.userName);

return NextResponse.json(
{
statusCode: signUpUser.status,
message: signUpUser.message
},
{ status: 200 }
);
}
75 changes: 30 additions & 45 deletions src/app/forgotPassword/page.jsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,36 @@
'use client'
import Link from "next/link"

import axios from 'axios';
import React, { useState } from 'react'

const ResetPassoword = () => {

const [userName, setuserName] = useState('priyalcoc2');
const [otp, setotp] = useState('');
const [newPassword, setnewPassword] = useState('');
const [errorMessage, seterrorMessage] = useState('');

async function resendOTP() {
const response = await axios.post('/api/resend', { userName, type: 'forgotPassword' });

const message = response.data.message;

seterrorMessage(message);
}

async function resetPassowrd() {
const response = await axios.post('/api/forgotPassword', { userName, otp, newPassword });

const message = response.data.message;
const statusCode = response.data.statusCode;

if (statusCode === 200) {

seterrorMessage(message);
setTimeout(() => {
window.location.href = '/';
}, 2000);

} else {
seterrorMessage(message);
}
}

const ForgotPasswordPage = () => {
return (
<div className='flex flex-col gap-4 mt-4 ml-8'>
<p><input value={userName} onChange={(e) => setuserName(e.target.value)} className='text-black pl-2 py-2 placeholder:text-black' placeholder='user name' type="text" /></p>
<p><input value={otp} onChange={(e) => setotp(e.target.value)} className='text-black pl-2 py-2 placeholder:text-black' placeholder='otp' type="otp" /></p>
<p><input value={newPassword} onChange={(e) => setnewPassword(e.target.value)} className='text-black pl-2 py-2 placeholder:text-black' placeholder='newPassword' type="newPassword" /></p>
{errorMessage && <p className='text-red-600'>{errorMessage}</p>}
<button onClick={resendOTP} className="text-left cursor-pointer">resendOTP</button>
<button onClick={resetPassowrd} className="text-left cursor-pointer">submit</button>
</div>
<>
<section className="bg-gray-50 dark:bg-gray-900">
<div className="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
<div className="w-full bg-white rounded-lg shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-gray-800 dark:border-gray-700">
<div className="p-6 space-y-4 md:space-y-6 sm:p-8">
<h1 className="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-white">
Create a new account
</h1>
<form className="space-y-4 md:space-y-6" action="#">
<div>
<label htmlFor="email" className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your email</label>
<input type="email" name="email" id="email" className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="[email protected]" required="" />
</div>
<div>
<label htmlFor="password" className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
<input type="password" name="password" id="password" placeholder="••••••••" className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required="" />
</div>
<button type="submit" className="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">Sign up</button>
<p className="text-sm font-light text-gray-500 dark:text-gray-400">
Already have an account? <Link href="/signIn" className="font-medium text-primary-600 hover:underline dark:text-primary-500">Sign In</Link>
</p>
</form>
</div>
</div>
</div>
</section>
</>
)
}

export default ResetPassoword
export default ForgotPasswordPage
Loading

0 comments on commit 6789d2f

Please sign in to comment.