Skip to content

Commit

Permalink
feat: Complete Login web UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxwell175 committed May 12, 2018
1 parent 915af32 commit 60dff6e
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
SSNFSd/config.db

*.db-journal

# C++ objects and libs

*.slo
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "Common/spdlog"]
path = Common/spdlog
url = https://github.com/gabime/spdlog.git
[submodule "SSNFSd/webpanel/crypto-js"]
path = SSNFSd/webpanel/crypto-js
url = https://github.com/MDTech-us-MAN/crypto-js.git
branch = master
3 changes: 3 additions & 0 deletions SSNFSd/SSNFSd.pro
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ DEFINES += "_CONFIG_DIR=\"\\\"$$PREFIX/etc\\\"\""

DEFINES += _FILE_OFFSET_BITS=64
DEFINES += _XOPEN_SOURCE=700

DISTFILES += \
webpanel/login.php
6 changes: 3 additions & 3 deletions SSNFSd/config.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ CREATE TABLE IF NOT EXISTS "Settings" (
PRIMARY KEY(`Setting_Key`)
);
INSERT INTO Settings VALUES('PrivateKeySource','file','Where is the private key?','2018-02-19 04:25:58','Default');
INSERT INTO Settings VALUES('PrivateKeyFilePath','/home/maxwell/CLionProjects/SSNFS/SSNFSd/test.key','If the private key is a file, this is the path to the file.','2018-02-19 04:25:58','Default');
INSERT INTO Settings VALUES('CertificatePath','/home/maxwell/CLionProjects/SSNFS/SSNFSd/test.crt','Path to the server''s certificate.','2018-02-19 04:25:58','Default');
INSERT INTO Settings VALUES('PrivateKeyFilePath','/home/maxwell/Coding/SSNFS/SSNFSd/test.key','If the private key is a file, this is the path to the file.','2018-02-19 04:25:58','Default');
INSERT INTO Settings VALUES('CertificatePath','/home/maxwell/Coding/SSNFS/SSNFSd/test.crt','Path to the server''s certificate.','2018-02-19 04:25:58','Default');
INSERT INTO Settings VALUES('ListenPort','2050','The port on which the server will listen for both client requests and Web Panel requests.','2018-03-05 07:18:50','Default');
INSERT INTO Settings VALUES('NewFileMode','777','The mode used to store the files that clients create. Does not affect actual client privileges.','2018-04-06 03:33:34','Default');
INSERT INTO Settings VALUES('WebPanelPath','/home/maxwell/CLionProjects/SSNFS/SSNFSd/webpanel','Path to the directory containing the web administration files. Before loading each file, it goes through a PHP parser.','2018-05-10 00:00:00','Default');
INSERT INTO Settings VALUES('WebPanelPath','/home/maxwell/Coding/SSNFS/SSNFSd/webpanel','Path to the directory containing the web administration files. Before loading each file, it goes through a PHP parser.','2018-05-10 00:00:00','Default');
CREATE TABLE IF NOT EXISTS "Shares" (
`Share_Key` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
`Share_Name` TEXT NOT NULL UNIQUE,
Expand Down
1 change: 1 addition & 0 deletions SSNFSd/webpanel/crypto-js
Submodule crypto-js added at 044661
92 changes: 92 additions & 0 deletions SSNFSd/webpanel/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
if (check_auth_cookie($_COOKIE['SSNFS_auth']) == TRUE) {
header("Location: /");
http_response_code(303);
exit();
}

if (isset($_POST['email'])) {
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login - SSNFS</title>

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">

<script type="text/javascript" src="crypto-js/build/rollups/sha512.js"></script>

<style>
html, body{height:100%; margin:0;padding:0}

.container-fluid{
height:100%;
display:table;
width: 100%;
padding: 0;
}

.row-fluid {height: 100%; display:table-cell; vertical-align: middle;}

.centering {
float:none;
margin:0 auto;
}

.card-body {
padding: 1em 2em;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<div class="col-md-5 centering">
<div class="card bg-light">
<article class="card-body">
<form action="login.php" method="post">
<h2><b>SSNFS</b></h2>
<h4>Login</h4>
<div class="form-group input-group">
<div class="input-group-prepend">
<span class="input-group-text"> <i class="fa fa-envelope"></i> </span>
</div>
<input name="email" autofocus="autofocus" class="form-control" placeholder="Email address" type="email">
</div> <!-- form-group// -->
<div class="form-group input-group">
<div class="input-group-prepend">
<span class="input-group-text"> <i class="fa fa-lock"></i> </span>
</div>
<input id="txtPassword" class="form-control" placeholder="Password" type="password" name="">
<input id="txtPasswordHash" type="hidden" name="passwordHash">
</div> <!-- form-group// -->
<div class="form-group">
<button id="btnLogin" type="submit" class="btn btn-primary btn-block"> Login </button>
</div> <!-- form-group// -->
</form>
</article>
</div> <!-- card.// -->
</div>
</div>
</div>
<script type="text/javascript">
var txtPassword = document.getElementById("txtPassword");
var txtPasswordHash = document.getElementById("txtPasswordHash");
var btnLogin = document.getElementById("frmLogin");

txtPassword.onkeyup = function() {
txtPasswordHash.value = CryptoJS.SHA512(txtPassword.value);
};

btnLogin.onclick = function () {
txtPassword.disabled = true;
txtPassword.value = '0'.repeat(txtPassword.value.length);
};
</script>
</body>
</html>

1 comment on commit 60dff6e

@Maxwell175
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#12

Please sign in to comment.