Skip to content

Commit

Permalink
fixed the login page rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaurya0108 committed Nov 8, 2023
1 parent 75b8184 commit f66b700
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
1 change: 1 addition & 0 deletions FrontEnd/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default function App() {

<Routes>
<Route path="/home" element={<Home/>} />
<Route path="/" element={<Login/>} />
</Routes>
);
}
47 changes: 24 additions & 23 deletions FrontEnd/src/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,36 @@ export default function Login() {
const [password, setPassword] = useState('');


// async function authorizeUser() {
// try{
// var credentials = JSON.stringify({
// "username": username,
// "password": password
// });
// var myHeaders = new Headers();
// myHeaders.append("Content-Type", "application/json");

var requestOptions = {
async function authorizeUser() {
try {
const credentials = JSON.stringify({
username,
password
});
const myHeaders = {
"Content-Type": "application/json"
};

const requestOptions = {
method: 'POST',
headers: myHeaders,
body: credentials,
redirect: 'follow',
credentials: 'include' //Make sure to have this line for every Request. Or else the cookie won't be included in the requests
credentials: 'include'
};
// const response = await fetch("http://18.189.195.246:443/auth/login", requestOptions);
const response = fetch("http://18.189.195.246:443/auth/login", requestOptions);


const response = await fetch("http://18.189.195.246:443/auth/login", requestOptions);
if (response.ok) {
navigator('home');
}
else {
navigator('/home');
} else {
alert('Invalid Credentials');
}
// }
// catch (err) {
// alert(err.message);
// }
// }
} catch (err) {
alert(err.message);
}
}



return (
Expand All @@ -63,9 +63,10 @@ export default function Login() {
placeholder="Password"
onChange={(e) => setPassword(e.target.value)} />
{/* <button className="login-button" onClick={authorizeUser}> */}
<button className="login-button" onClick={"hello"}>
<button className="login-button" onClick={authorizeUser}>
LOGIN
</button>

</div>
</div>
)
Expand Down

0 comments on commit f66b700

Please sign in to comment.