Skip to content

Commit

Permalink
fix(frontend): update frontend redirect logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Urban committed Oct 21, 2023
1 parent beb65df commit da1433e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<Link class="nav-link" to="/">Login</Link>
<Link class="nav-link" to="/login">Login</Link>
</li>
<li class="nav-item active">
<Link class="nav-link" to="/register">Register</Link>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/LandingPage.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="container mt-5">
<img src="/Kubevoyage.png" alt="Logo"/>
</div>
13 changes: 11 additions & 2 deletions frontend/src/Login.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@
let message = '';
async function login() {
console.log("test1")
try {
const response = await fetch('/api/login', {
method: 'POST',
credentials: "include",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ email, password })
});
const data = await response.json();
console.log(response)
//const data = await response.json();
console.log("test.2")
if (response.ok) {
console.log("test2")
message = "Login successful!";
navigate("/")
setTimeout(()=> {
window.location.href = "/api/redirect"
},2000)
// Optionally, set a token, redirect the user, or perform other actions
// For example: localStorage.setItem('token', data.token);
} else {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import Login from './Login.svelte';
import Requests from './Requests.svelte';
import Register from "./Register.svelte";
import Request from "../Request.svelte";
import LandingPage from "./LandingPage.svelte";

const routes = {
'/': Login,
'/': LandingPage,
'/login': Login,
'/requests': Requests,
'/register': Register,
'/request': Request
Expand Down

0 comments on commit da1433e

Please sign in to comment.