Created Administrative Sign in screen
This commit is contained in:
parent
2c082627e2
commit
8b88dffd84
@ -21,11 +21,8 @@ zip-extract = "0.1.3"
|
|||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
gethostname = "0.4.3"
|
gethostname = "0.4.3"
|
||||||
self_update = "0.40.0"
|
self_update = "0.40.0"
|
||||||
|
parking_lot = "0.12.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
||||||
custom-protocol = ["tauri/custom-protocol"]
|
custom-protocol = ["tauri/custom-protocol"]
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "FCLauncher"
|
|
||||||
path = "src/main.rs"
|
|
||||||
|
15
FCLauncher/src-tauri/src/admin.rs
Normal file
15
FCLauncher/src-tauri/src/admin.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
use crate::ftp::{self, test_cred};
|
||||||
|
|
||||||
|
static USERNAME: parking_lot::Mutex<String> = parking_lot::const_mutex(String::new());
|
||||||
|
static PASSWORD: parking_lot::Mutex<String> = parking_lot::const_mutex(String::new());
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn login(username: String, password: String, window: tauri::Window) {
|
||||||
|
if(test_cred(username.as_str(), password.as_str())){
|
||||||
|
*USERNAME.lock() = username;
|
||||||
|
*PASSWORD.lock() = password;
|
||||||
|
window.emit("Login_Success", {});
|
||||||
|
}else{
|
||||||
|
window.emit("Login_Failed", {});
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,10 @@ fn ftp_connection_anonymous() -> Result<NativeTlsFtpStream, FtpError>{
|
|||||||
ftp_connection("anonymous", "anonymous@")
|
ftp_connection("anonymous", "anonymous@")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn test_cred(username: &str, password: &str) -> bool{
|
||||||
|
return ftp_connection(username, password).is_ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn ftp_connection(username: &str, password: &str) -> Result<NativeTlsFtpStream, FtpError>{
|
fn ftp_connection(username: &str, password: &str) -> Result<NativeTlsFtpStream, FtpError>{
|
||||||
let ftp_stream = NativeTlsFtpStream::connect("gitea.piwalker.net:21").unwrap_or_else(|err|
|
let ftp_stream = NativeTlsFtpStream::connect("gitea.piwalker.net:21").unwrap_or_else(|err|
|
||||||
@ -20,10 +24,13 @@ fn ftp_connection(username: &str, password: &str) -> Result<NativeTlsFtpStream,
|
|||||||
let cert = include_bytes!("../res/vsftpd.crt");
|
let cert = include_bytes!("../res/vsftpd.crt");
|
||||||
let cert = Certificate::from_pem(cert).unwrap();
|
let cert = Certificate::from_pem(cert).unwrap();
|
||||||
let mut ftp_stream = ftp_stream.into_secure(NativeTlsConnector::from(TlsConnector::builder().add_root_certificate(cert).build().unwrap()), "gitea.piwalker.net").unwrap();
|
let mut ftp_stream = ftp_stream.into_secure(NativeTlsConnector::from(TlsConnector::builder().add_root_certificate(cert).build().unwrap()), "gitea.piwalker.net").unwrap();
|
||||||
ftp_stream.login("anonymous", "anonymous@").map(|_| Ok(ftp_stream)).unwrap()
|
let result = ftp_stream.login(username, password);
|
||||||
|
if result.is_ok() {
|
||||||
|
return Ok(ftp_stream);
|
||||||
|
}
|
||||||
|
Err(result.unwrap_err())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn ftp_retr(window: Option<tauri::Window>, file: PathBuf , mut writer: impl Write, mut callback: impl FnMut(Option<tauri::Window>, usize, usize)) -> Result<bool, FtpError> {
|
pub fn ftp_retr(window: Option<tauri::Window>, file: PathBuf , mut writer: impl Write, mut callback: impl FnMut(Option<tauri::Window>, usize, usize)) -> Result<bool, FtpError> {
|
||||||
let mut ftp_stream = ftp_connection_anonymous().unwrap();
|
let mut ftp_stream = ftp_connection_anonymous().unwrap();
|
||||||
let file = file.to_str().unwrap().replace("\\", "/");
|
let file = file.to_str().unwrap().replace("\\", "/");
|
||||||
|
@ -15,6 +15,7 @@ mod prism;
|
|||||||
mod system_dirs;
|
mod system_dirs;
|
||||||
mod util;
|
mod util;
|
||||||
mod modpack;
|
mod modpack;
|
||||||
|
mod admin;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct ModpackEntry{
|
struct ModpackEntry{
|
||||||
@ -33,7 +34,7 @@ fn main() {
|
|||||||
modpack::get_modpacks();
|
modpack::get_modpacks();
|
||||||
//prism::install_prism();
|
//prism::install_prism();
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.invoke_handler(tauri::generate_handler![greet, modpack::get_modpacks, modpack::launch_modpack, prism::launch_prism, prism::install_prism])
|
.invoke_handler(tauri::generate_handler![greet, modpack::get_modpacks, modpack::launch_modpack, prism::launch_prism, prism::install_prism, admin::login])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
30
FCLauncher/src/Admin.html
Normal file
30
FCLauncher/src/Admin.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="stylesheet" href="styles.css" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-width=cover" />
|
||||||
|
<title>Tauri App</title>
|
||||||
|
<script type="module" src="/admin.js" defer></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="Logo">
|
||||||
|
<button id="back"></button>
|
||||||
|
<img src="assets/Title.png" alt="Title" id="Title">
|
||||||
|
</div>
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progressFinished"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container" data-bs-theme="dark">
|
||||||
|
<h1>Administration</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
33
FCLauncher/src/Login.html
Normal file
33
FCLauncher/src/Login.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="stylesheet" href="styles.css" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-width=cover" />
|
||||||
|
<title>Tauri App</title>
|
||||||
|
<script type="module" src="/login.js" defer></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="Logo">
|
||||||
|
<button id="back"></button>
|
||||||
|
<img src="assets/Title.png" alt="Title" id="Title">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container" data-bs-theme="dark">
|
||||||
|
<p class="Error" id="Incorrect">Username or Password is incorrect!</p>
|
||||||
|
<input id="Username" placeholder="Username" />
|
||||||
|
<input id="Password" placeholder="Password" type="password" />
|
||||||
|
<div class="loginButtons">
|
||||||
|
<button id="Cancel">Cancel</button>
|
||||||
|
<button id="Login">Login</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
36
FCLauncher/src/admin.js
Normal file
36
FCLauncher/src/admin.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
const { invoke } = window.__TAURI__.tauri;
|
||||||
|
const { listen } = window.__TAURI__.event;
|
||||||
|
const { ask } = window.__TAURI__.dialog;
|
||||||
|
const downBar = document.querySelector(".progressFinished");
|
||||||
|
//import { listen } from '@tauri-apps/api';
|
||||||
|
|
||||||
|
const download_progress = listen("download_progress", (progress) => {
|
||||||
|
console.log("Downloading");
|
||||||
|
//console.log("Downloaded "+progress.payload.downloaded/(1024*1024) +"MB / " + progress.payload.total/(1024*1024) + "MB");
|
||||||
|
let downProgress = (progress.payload.downloaded/(1024*1024)).toFixed(2);
|
||||||
|
let downTotal = (progress.payload.total/(1024*1024)).toFixed(2);
|
||||||
|
document.getElementById("download_name").textContent = "Downloading "+progress.payload.download_name;
|
||||||
|
document.getElementById("download_progress").textContent = downProgress + "MB / "+downTotal+"MB";
|
||||||
|
document.getElementById("launchGame").disabled = true;
|
||||||
|
downBar.style.width = `${(progress.payload.downloaded / progress.payload.total) * 100}%`;
|
||||||
|
document.querySelector(".progress").style.visibility = "visible";
|
||||||
|
});
|
||||||
|
|
||||||
|
const download_finished = listen("download_finished", (event) => {
|
||||||
|
document.getElementById("download_name").textContent = "";
|
||||||
|
document.getElementById("download_progress").textContent = "";
|
||||||
|
document.getElementById("launchGame").disabled = false;
|
||||||
|
document.getElementById("launchGame").textContent ="Launch Minecraft";
|
||||||
|
downBar.style.width = 0;
|
||||||
|
document.querySelector(".progress").style.visibility = "hidden";
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|
||||||
|
document.getElementById("back").addEventListener("click", back);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function back(){
|
||||||
|
window.location.href = "index.html";
|
||||||
|
}
|
BIN
FCLauncher/src/assets/back.png
Normal file
BIN
FCLauncher/src/assets/back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
FCLauncher/src/assets/settings.jpg
Normal file
BIN
FCLauncher/src/assets/settings.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
BIN
FCLauncher/src/assets/settings.png
Normal file
BIN
FCLauncher/src/assets/settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.5 KiB |
@ -15,6 +15,7 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="Logo">
|
<div class="Logo">
|
||||||
|
<button id="settings"></button>
|
||||||
<img src="assets/Title.png" alt="Title" id="Title">
|
<img src="assets/Title.png" alt="Title" id="Title">
|
||||||
</div>
|
</div>
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
|
37
FCLauncher/src/login.js
Normal file
37
FCLauncher/src/login.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
const { invoke } = window.__TAURI__.tauri;
|
||||||
|
const { listen } = window.__TAURI__.event;
|
||||||
|
const { ask } = window.__TAURI__.dialog;
|
||||||
|
const downBar = document.querySelector(".progressFinished");
|
||||||
|
//import { listen } from '@tauri-apps/api';
|
||||||
|
|
||||||
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|
||||||
|
document.getElementById("back").addEventListener("click", back);
|
||||||
|
document.getElementById("Cancel").addEventListener("click", back);
|
||||||
|
document.getElementById("Login").addEventListener("click", login);
|
||||||
|
document.getElementById("Password").addEventListener("keypress", keypress);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function back(){
|
||||||
|
window.location.href = "index.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
function login(){
|
||||||
|
invoke("login", { username: document.getElementById("Username").value, password: document.getElementById("Password").value});
|
||||||
|
}
|
||||||
|
|
||||||
|
function keypress(e){
|
||||||
|
if(e.keyCode === 13){
|
||||||
|
e.preventDefault();
|
||||||
|
login();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const failed = listen("Login_Failed", (event) => {
|
||||||
|
document.getElementById("Incorrect").style.visibility = "visible";
|
||||||
|
})
|
||||||
|
|
||||||
|
const success = listen("Login_Success", (event) => {
|
||||||
|
window.location.href = "Admin.html";
|
||||||
|
})
|
@ -33,6 +33,8 @@ window.addEventListener("DOMContentLoaded", () => {
|
|||||||
|
|
||||||
document.getElementById("launchGame").addEventListener("click", gameLaunch);
|
document.getElementById("launchGame").addEventListener("click", gameLaunch);
|
||||||
document.getElementById("prism").addEventListener("click", prism);
|
document.getElementById("prism").addEventListener("click", prism);
|
||||||
|
document.getElementById("settings").addEventListener("click", login);
|
||||||
|
document.getElementById("back").addEventListener("click", back);
|
||||||
|
|
||||||
});
|
});
|
||||||
function packSelect() {
|
function packSelect() {
|
||||||
@ -40,6 +42,15 @@ function packSelect() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function login(){
|
||||||
|
window.location.href = "Login.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
function back(){
|
||||||
|
console.log("test");
|
||||||
|
window.location.href = "index.html";
|
||||||
|
}
|
||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
console.log("loading");
|
console.log("loading");
|
||||||
var dropdown = document.getElementById("Modpacks");
|
var dropdown = document.getElementById("Modpacks");
|
||||||
|
@ -228,3 +228,49 @@ button {
|
|||||||
display: block;
|
display: block;
|
||||||
margin: 0.5em;
|
margin: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#settings{
|
||||||
|
width: 2em;
|
||||||
|
height: 2.5em;
|
||||||
|
top: 5px;
|
||||||
|
left: 5px;
|
||||||
|
float: right;
|
||||||
|
position: absolute;
|
||||||
|
background-image: url('assets/settings.png');
|
||||||
|
background-size:cover;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
#back{
|
||||||
|
width: 2em;
|
||||||
|
height: 2.5em;
|
||||||
|
top: 5px;
|
||||||
|
left: 5px;
|
||||||
|
float: right;
|
||||||
|
position: absolute;
|
||||||
|
background-image: url('assets/back.png');
|
||||||
|
background-size:cover;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container input{
|
||||||
|
margin: 0.5em;
|
||||||
|
width: 45%
|
||||||
|
}
|
||||||
|
|
||||||
|
.loginButtons{
|
||||||
|
display: flex;
|
||||||
|
margin: 0.5em;
|
||||||
|
flex-direction: row;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
width: 50%;
|
||||||
|
gap: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Error{
|
||||||
|
color: black;
|
||||||
|
background-color: red;
|
||||||
|
margin: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user