login page
This commit is contained in:
parent
079726fee6
commit
a495798aee
@ -7,12 +7,12 @@ public class main {
|
||||
D.getdata();
|
||||
D.printList();
|
||||
*/
|
||||
// Thread mythread = new Thread(() -> new Webserver().startserver());
|
||||
// mythread.start();
|
||||
//
|
||||
//
|
||||
// System.out.println("thread started");
|
||||
Thread mythread = new Thread(() -> new website.Webserver().startserver());
|
||||
mythread.start();
|
||||
|
||||
new jdcb().executeQuery("select * from user");
|
||||
|
||||
System.out.println("thread started");
|
||||
|
||||
//new jdcb().executeQuery("select * from user");
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
package website;
|
||||
|
||||
import com.sun.net.httpserver.Headers;
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
@ -7,8 +9,12 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Webserver{
|
||||
public void startserver(){
|
||||
@ -20,18 +26,38 @@ public class Webserver{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
server.createContext("/", new MyHandler());
|
||||
server.createContext("/", new MainPage());
|
||||
|
||||
//receiving get and post data todo
|
||||
server.createContext("/senddata/test", new HttpHandler() {
|
||||
@Override
|
||||
public void handle(HttpExchange httpExchange) throws IOException {
|
||||
server.createContext("/senddata/loginget", httpExchange -> {
|
||||
if (httpExchange.getRequestMethod().equals("GET")){
|
||||
String query = httpExchange.getRequestURI().getQuery();
|
||||
System.out.println(query);
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
|
||||
String[] res = query.split("&");
|
||||
for (String str : res){
|
||||
String[] values = str.split("=");
|
||||
params.put(values[0],values[1]);
|
||||
|
||||
}
|
||||
String password = params.get("password");
|
||||
String username = params.get("username");
|
||||
|
||||
System.out.println(StringToMD5(password));
|
||||
//TODO check if user exists in database
|
||||
|
||||
|
||||
//send response
|
||||
String response = "{\"accept\": true}";
|
||||
|
||||
Headers h = httpExchange.getResponseHeaders();
|
||||
h.set("Content-Type", "application/json");
|
||||
httpExchange.sendResponseHeaders(200, 0);
|
||||
|
||||
OutputStream os = httpExchange.getResponseBody();
|
||||
os.write(response.getBytes());
|
||||
os.close();
|
||||
}
|
||||
});
|
||||
|
||||
@ -39,7 +65,19 @@ public class Webserver{
|
||||
server.start();
|
||||
}
|
||||
|
||||
static class MyHandler implements HttpHandler {
|
||||
public String StringToMD5(String value){
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] messageDigest = md.digest(value.getBytes());
|
||||
BigInteger no = new BigInteger(1, messageDigest);
|
||||
return no.toString(16);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
static class MainPage implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange t) throws IOException {
|
||||
System.out.println("a new request...");
|
@ -1,8 +1,89 @@
|
||||
.test{
|
||||
background-color: #7F7F7F;
|
||||
/* Made with love by Mutiullah Samim*/
|
||||
|
||||
@import url('https://fonts.googleapis.com/css?family=Numans');
|
||||
|
||||
html,body{
|
||||
background-image: url('../rsc/login2.jpg');
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
height: 100%;
|
||||
font-family: 'Numans', sans-serif;
|
||||
}
|
||||
|
||||
.optionsarray{
|
||||
margin-left: 20mm;
|
||||
margin-top: 20mm;
|
||||
.container{
|
||||
height: 100%;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.card{
|
||||
height: 370px;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
width: 400px;
|
||||
background-color: rgba(0,0,0,0.5) !important;
|
||||
}
|
||||
|
||||
.social_icon span{
|
||||
font-size: 60px;
|
||||
margin-left: 10px;
|
||||
color: #FFC312;
|
||||
}
|
||||
|
||||
.social_icon span:hover{
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.card-header h3{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.social_icon{
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: -45px;
|
||||
}
|
||||
|
||||
.input-group-prepend span{
|
||||
width: 50px;
|
||||
background-color: #FFC312;
|
||||
color: black;
|
||||
border:0 !important;
|
||||
}
|
||||
|
||||
input:focus{
|
||||
outline: 0 0 0 0 !important;
|
||||
box-shadow: 0 0 0 0 !important;
|
||||
|
||||
}
|
||||
|
||||
.remember{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.remember input
|
||||
{
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-left: 15px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.login_btn{
|
||||
color: black;
|
||||
background-color: #FFC312;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.login_btn:hover{
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.links{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.links a{
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
@ -1,89 +0,0 @@
|
||||
/* Made with love by Mutiullah Samim*/
|
||||
|
||||
@import url('https://fonts.googleapis.com/css?family=Numans');
|
||||
|
||||
html,body{
|
||||
background-image: url('../rsc/login2.jpg');
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
height: 100%;
|
||||
font-family: 'Numans', sans-serif;
|
||||
}
|
||||
|
||||
.container{
|
||||
height: 100%;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.card{
|
||||
height: 370px;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
width: 400px;
|
||||
background-color: rgba(0,0,0,0.5) !important;
|
||||
}
|
||||
|
||||
.social_icon span{
|
||||
font-size: 60px;
|
||||
margin-left: 10px;
|
||||
color: #FFC312;
|
||||
}
|
||||
|
||||
.social_icon span:hover{
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.card-header h3{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.social_icon{
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: -45px;
|
||||
}
|
||||
|
||||
.input-group-prepend span{
|
||||
width: 50px;
|
||||
background-color: #FFC312;
|
||||
color: black;
|
||||
border:0 !important;
|
||||
}
|
||||
|
||||
input:focus{
|
||||
outline: 0 0 0 0 !important;
|
||||
box-shadow: 0 0 0 0 !important;
|
||||
|
||||
}
|
||||
|
||||
.remember{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.remember input
|
||||
{
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-left: 15px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.login_btn{
|
||||
color: black;
|
||||
background-color: #FFC312;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.login_btn:hover{
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.links{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.links a{
|
||||
margin-left: 4px;
|
||||
}
|
8
wwwroot/css/settings.css
Normal file
8
wwwroot/css/settings.css
Normal file
@ -0,0 +1,8 @@
|
||||
.test{
|
||||
background-color: #7F7F7F;
|
||||
}
|
||||
|
||||
.optionsarray{
|
||||
margin-left: 20mm;
|
||||
margin-top: 20mm;
|
||||
}
|
@ -2,7 +2,8 @@
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<title>Login Page</title>
|
||||
<!--Made with love by Mutiullah Samim -->
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="lib/bootstrap.min.css">
|
||||
@ -16,39 +17,54 @@
|
||||
<!-- Latest compiled JavaScript -->
|
||||
<script src="lib/bootstrap.min.js"></script>
|
||||
|
||||
<!--Fontawesome CDN-->
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
|
||||
|
||||
<!--Custom styles-->
|
||||
<link rel="stylesheet" type="text/css" href="css/index.css">
|
||||
<script type="text/javascript" src="js/index.js"> </script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Grey with black text -->
|
||||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="#">Active</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled" href="#">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="optionsarray">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="customSwitch1">
|
||||
<label class="custom-control-label" for="customSwitch1">Setting 1</label>
|
||||
</div>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="customSwitch2">
|
||||
<label class="custom-control-label" for="customSwitch2">Setting 2</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="js/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="d-flex justify-content-center h-100">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Sign In</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form>
|
||||
<div class="input-group form-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-user"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" placeholder="username" id="userfield">
|
||||
|
||||
</body>
|
||||
</div>
|
||||
<div class="input-group form-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-key"></i></span>
|
||||
</div>
|
||||
<input type="password" class="form-control" placeholder="password" id="passfield">
|
||||
</div>
|
||||
<div class="row align-items-center remember">
|
||||
<input type="checkbox">Remember Me
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Login" class="btn float-right login_btn" id="loginbtn">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="d-flex justify-content-center links">
|
||||
Don't have an account?<a href="#">Sign Up</a>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<a href="#">Forgot your password?</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,3 +1,18 @@
|
||||
$(document).ready(function() {
|
||||
console.log("hey from js");
|
||||
$('#loginbtn').click(function(e) {
|
||||
e.preventDefault();
|
||||
console.log("clicked login button");
|
||||
var username = $("#userfield")[0].value;
|
||||
var password = $("#passfield")[0].value;
|
||||
|
||||
$.get('/senddata/loginget?username='+username+'&password='+password,function(data){
|
||||
|
||||
console.log(data);
|
||||
if (data.accept == true) {
|
||||
console.log("successfully logged in!");
|
||||
document.cookie = "username="+username;
|
||||
window.location = 'settings.html';
|
||||
}
|
||||
},'json');
|
||||
});
|
||||
});
|
||||
|
3
wwwroot/js/settings.js
Normal file
3
wwwroot/js/settings.js
Normal file
@ -0,0 +1,3 @@
|
||||
$(document).ready(function() {
|
||||
console.log("hey from js");
|
||||
});
|
@ -1,67 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login Page</title>
|
||||
<!--Made with love by Mutiullah Samim -->
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="lib/bootstrap.min.css">
|
||||
|
||||
<!-- jQuery library -->
|
||||
<script src="lib/jquery.min.js"></script>
|
||||
|
||||
<!-- Popper JS -->
|
||||
<script src="lib/popper.min.js"></script>
|
||||
|
||||
<!-- Latest compiled JavaScript -->
|
||||
<script src="lib/bootstrap.min.js"></script>
|
||||
|
||||
<!--Fontawesome CDN-->
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
|
||||
|
||||
<!--Custom styles-->
|
||||
<link rel="stylesheet" type="text/css" href="css/login.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="d-flex justify-content-center h-100">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Sign In</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form>
|
||||
<div class="input-group form-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-user"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" placeholder="username">
|
||||
|
||||
</div>
|
||||
<div class="input-group form-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-key"></i></span>
|
||||
</div>
|
||||
<input type="password" class="form-control" placeholder="password">
|
||||
</div>
|
||||
<div class="row align-items-center remember">
|
||||
<input type="checkbox">Remember Me
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Login" class="btn float-right login_btn">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="d-flex justify-content-center links">
|
||||
Don't have an account?<a href="#">Sign Up</a>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<a href="#">Forgot your password?</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
54
wwwroot/settings.html
Normal file
54
wwwroot/settings.html
Normal file
@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="lib/bootstrap.min.css">
|
||||
|
||||
<!-- jQuery library -->
|
||||
<script src="lib/jquery.min.js"></script>
|
||||
|
||||
<!-- Popper JS -->
|
||||
<script src="lib/popper.min.js"></script>
|
||||
|
||||
<!-- Latest compiled JavaScript -->
|
||||
<script src="lib/bootstrap.min.js"></script>
|
||||
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="css/settings.css">
|
||||
<script type="text/javascript" src="js/settings.js"> </script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Grey with black text -->
|
||||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="#">Active</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled" href="#">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="optionsarray">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="customSwitch1">
|
||||
<label class="custom-control-label" for="customSwitch1">Setting 1</label>
|
||||
</div>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="customSwitch2">
|
||||
<label class="custom-control-label" for="customSwitch2">Setting 2</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user