Login Function added
This commit is contained in:
@@ -1,22 +0,0 @@
|
|||||||
import {useState} from "react";
|
|
||||||
import Button from "@/components/Button";
|
|
||||||
|
|
||||||
export default function Login() {
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="border">
|
|
||||||
<login className={"login-container"}>
|
|
||||||
<p className={"font-big-fat placement"}>Login</p>
|
|
||||||
<div className={"placement"}>
|
|
||||||
<br/>
|
|
||||||
<p className={"font-kinda-big"}>Username</p>
|
|
||||||
<input type="text" placeholder="Type here" className="input input-bordered input-sm w-full max-w-xs"/>
|
|
||||||
<br/>
|
|
||||||
<p className={"font-kinda-big"}>Password</p>
|
|
||||||
<input type="text" placeholder="Type here" className="input input-bordered input-sm w-full max-w-xs"/>
|
|
||||||
</div>
|
|
||||||
<Button text={"Login"} color={"#e2001a"} width={"25px"}/>
|
|
||||||
</login>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import {useState} from "react";
|
||||||
|
import Button from "@/components/Button";
|
||||||
|
|
||||||
|
export default function Login() {
|
||||||
|
|
||||||
|
let url = "http://localhost:8080/users"
|
||||||
|
|
||||||
|
function on_login_click()
|
||||||
|
{
|
||||||
|
url += "?mail=" + inputUserName + "&password=" + inputPassword;
|
||||||
|
|
||||||
|
fetch(url, {
|
||||||
|
method: "GET",
|
||||||
|
}).then(r => console.log())
|
||||||
|
}
|
||||||
|
|
||||||
|
const [inputUserName, setInputUserName] = useState("")
|
||||||
|
const [inputPassword, setInputPassword] = useState("")
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="border">
|
||||||
|
<login className={"login-container"}>
|
||||||
|
<p className={"font-big-fat placement"}>Login</p>
|
||||||
|
<div className={"placement"}>
|
||||||
|
<br/>
|
||||||
|
<p className={"font-kinda-big"}>Username</p>
|
||||||
|
<input type="text" value={inputUserName} onChange={e => setInputUserName(e.target.value)} placeholder="Type here" className="input input-bordered input-sm w-full max-w-xs"/>
|
||||||
|
<br/>
|
||||||
|
<p className={"font-kinda-big"}>Password</p>
|
||||||
|
<input type="password" value={inputPassword} onChange={e => setInputPassword(e.target.value)} placeholder="Type here" className="input input-bordered input-sm w-full max-w-xs"/>
|
||||||
|
</div>
|
||||||
|
<Button text={"Login"} color={"#e2001a"} width={"25px"} onClick={() => on_login_click()}/>
|
||||||
|
</login>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import PopUp from "@/components/PopUp";
|
|||||||
import CalenderView from "@/components/CalenderView";
|
import CalenderView from "@/components/CalenderView";
|
||||||
import DateElement from "@/components/DateElement";
|
import DateElement from "@/components/DateElement";
|
||||||
import InputForm from "@/components/InputForm";
|
import InputForm from "@/components/InputForm";
|
||||||
import Login from "@/Tests/Login";
|
import Login from "@/components/Login";
|
||||||
import Test from "@/components/Test";
|
import Test from "@/components/Test";
|
||||||
|
|
||||||
|
|
||||||
@@ -20,13 +20,9 @@ export default function Home(p) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<>
|
<div className={"login-window"}>
|
||||||
|
<Login/>
|
||||||
|
</div>
|
||||||
<div style={{height: 50}}></div>
|
|
||||||
<Test/>
|
|
||||||
|
|
||||||
</>
|
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -8,19 +8,22 @@
|
|||||||
--background-end-rgb: 255, 255, 255;
|
--background-end-rgb: 255, 255, 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Page Layouts
|
||||||
|
*/
|
||||||
|
|
||||||
body {
|
.login-window
|
||||||
color: rgb(var(--foreground-rgb));
|
{
|
||||||
background: linear-gradient(
|
height: 100vh;
|
||||||
to bottom,
|
|
||||||
transparent,
|
|
||||||
rgb(var(--background-end-rgb))
|
|
||||||
)
|
|
||||||
rgb(var(--background-start-rgb));
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -397,7 +400,6 @@ Login
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-family: Arial, serif;
|
font-family: Arial, serif;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-color: black;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.border{
|
.border{
|
||||||
@@ -407,7 +409,7 @@ Login
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
border-color: #1e2428;
|
border-color: #1e2428;
|
||||||
gap: 10px;
|
/*gap: 10px;*/
|
||||||
}
|
}
|
||||||
.placement {
|
.placement {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -14,5 +14,4 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [require("daisyui")],
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,50 +13,50 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class ModuleController {
|
public class ModuleController {
|
||||||
private final DataBaseHandler db;
|
// private final DataBaseHandler db;
|
||||||
|
//
|
||||||
{
|
// {
|
||||||
db = DataBaseHandler.getInstance();
|
// db = DataBaseHandler.getInstance();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@CrossOrigin
|
// @CrossOrigin
|
||||||
@GetMapping("placeholder")
|
// @GetMapping("placeholder")
|
||||||
public ResponseEntity<Module> getModule(
|
// public ResponseEntity<Module> getModule(
|
||||||
@RequestParam(name="id") int id,
|
// @RequestParam(name="id") int id,
|
||||||
@RequestParam(name="sessionid") String sessionID) {
|
// @RequestParam(name="sessionid") String sessionID) {
|
||||||
|
//
|
||||||
User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
// User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
||||||
|
//
|
||||||
if (user != null){
|
// if (user != null){
|
||||||
Module module = db.getModule(id);
|
// Module module = db.getModule(id);
|
||||||
if(module != null) {
|
// if(module != null) {
|
||||||
return new ResponseEntity<>(module, HttpStatus.OK);
|
// return new ResponseEntity<>(module, HttpStatus.OK);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
// return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
// return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@CrossOrigin
|
// @CrossOrigin
|
||||||
@GetMapping("placeholder")
|
// @GetMapping("placeholder")
|
||||||
public ResponseEntity<Module> getModule(
|
// public ResponseEntity<Module> getModule(
|
||||||
@RequestParam(name="name") String name,
|
// @RequestParam(name="name") String name,
|
||||||
@RequestParam(name="sessionid") String sessionID) {
|
// @RequestParam(name="sessionid") String sessionID) {
|
||||||
|
//
|
||||||
User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
// User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
||||||
|
//
|
||||||
if(user != null)
|
// if(user != null)
|
||||||
{
|
// {
|
||||||
Module module = db.getModule(name);
|
// Module module = db.getModule(name);
|
||||||
if (module != null) {
|
// if (module != null) {
|
||||||
return new ResponseEntity<>(module, HttpStatus.OK);
|
// return new ResponseEntity<>(module, HttpStatus.OK);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
// return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
// return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user