Compare commits
12 Commits
074b3f8f31
...
cacddd16e2
| Author | SHA1 | Date | |
|---|---|---|---|
| cacddd16e2 | |||
| 2f6ff081f3 | |||
| 59bc23bdc2 | |||
| a7c33392ce | |||
| 05e01f4b23 | |||
| e2f4a0692c | |||
| efd7d15722 | |||
| 4e412e9c18 | |||
| 6220021953 | |||
|
|
01ca68e16b | ||
|
|
6c435e6135 | ||
|
|
e1f992e052 |
@@ -309,6 +309,47 @@ func cleanupSessions() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func changePasswordHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// exist, sessionData := validateSession(r)
|
||||||
|
// if !exist {
|
||||||
|
// http.Redirect(w, r, "/login", http.StatusSeeOther)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// err := r.ParseMultipartForm(10 << 20) // 10MB limit
|
||||||
|
// if err != nil {
|
||||||
|
// http.Error(w, "Bad request", http.StatusBadRequest)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if r.FormValue("csrf_token") != sessionData.CSRFToken {
|
||||||
|
// http.Error(w, "CSRF Forbidden", http.StatusForbidden)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// file, header, err := r.FormFile("photo")
|
||||||
|
// if err != nil {
|
||||||
|
// http.Error(w, "File not found", http.StatusBadRequest)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// defer file.Close()
|
||||||
|
// if header.Size > (10 * 1024 * 1024) {
|
||||||
|
// http.Error(w, "File is to large (limit is 10 MB)", http.StatusBadRequest)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 3. Read file into memory
|
||||||
|
// data, err := io.ReadAll(file)
|
||||||
|
// if err != nil {
|
||||||
|
// http.Error(w, "Failed to read file", http.StatusInternalServerError)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// userDN := fmt.Sprintf("uid=%s,cn=users,cn=accounts,%s", sessionData.data.Username, serverConfig.LDAPConfig.BaseDN)
|
||||||
|
// ldapServerMutex.Lock()
|
||||||
|
// defer ldapServerMutex.Unlock()
|
||||||
|
// modifyLDAPAttribute(ldapServer, userDN, "jpegphoto", []string{string(data)})
|
||||||
|
// createUserPhoto(sessionData.data.Username, data)
|
||||||
|
// }
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logging.Info("Starting the server")
|
logging.Info("Starting the server")
|
||||||
|
|
||||||
|
|||||||
@@ -6,17 +6,19 @@
|
|||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
/>
|
/>
|
||||||
<link rel="stylesheet" href="static/style.css" />
|
<link rel="stylesheet" href="static/style.css" />
|
||||||
|
<link rel="stylesheet" href="static/error/error.css" />
|
||||||
|
<link rel="stylesheet" href="static/card.css" />
|
||||||
<link rel="stylesheet" href="static/login_page.css" />
|
<link rel="stylesheet" href="static/login_page.css" />
|
||||||
|
|
||||||
<img id="logo_image" alt="logo" src="/logo" />
|
<img id="logo_image" alt="logo" src="/logo" />
|
||||||
<form id="login_card" method="POST">
|
<form id="login_card" class="card" method="POST">
|
||||||
<div id="welcome_text">
|
<div id="welcome_text">
|
||||||
Welcome to Astral Tech, Please Sign in to your account below
|
Welcome to Astral Tech, Please Sign in to your account below
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="incorrect_password_text" class="{{.IsHiddenClassList}}">
|
<div class="error {{.IsHiddenClassList}}">
|
||||||
⚠️ Invalid username or password.
|
⚠️ Invalid username or password.
|
||||||
<button id="incorrect_password_close_button">X</button>
|
<button class="close_error_button">X</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -31,12 +33,4 @@
|
|||||||
<button type="submit">Login</button>
|
<button type="submit">Login</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script src="/static/error/error.js" type="text/javascript"></script>
|
||||||
document
|
|
||||||
.getElementById("incorrect_password_close_button")
|
|
||||||
.addEventListener("click", function () {
|
|
||||||
document
|
|
||||||
.getElementById("incorrect_password_text")
|
|
||||||
.classList.add("hidden");
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -7,8 +7,33 @@
|
|||||||
/>
|
/>
|
||||||
<link rel="stylesheet" href="static/style.css" />
|
<link rel="stylesheet" href="static/style.css" />
|
||||||
<link rel="stylesheet" href="static/card.css" />
|
<link rel="stylesheet" href="static/card.css" />
|
||||||
|
<link rel="stylesheet" href="static/error/error.css" />
|
||||||
<link rel="stylesheet" href="static/profile_page.css" />
|
<link rel="stylesheet" href="static/profile_page.css" />
|
||||||
|
|
||||||
|
<div id="popup_background" class="blocked hidden"></div>
|
||||||
|
|
||||||
|
<div id="change_password_dialouge" class="hidden card">
|
||||||
|
<div id="password_error" class="error hidden">
|
||||||
|
<div id="password_text"></div>
|
||||||
|
<button id="password_error_close_button" class="close_error_button">
|
||||||
|
X
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
id="current_password"
|
||||||
|
placeholder="Current Password"
|
||||||
|
/>
|
||||||
|
<input type="password" id="new_password" placeholder="New Password" />
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
id="new_password_repeat"
|
||||||
|
placeholder="New Password(repeat)"
|
||||||
|
/>
|
||||||
|
<button id="final_change_password_button">Change Password</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<img id="logo_image" alt="logo" src="/logo" />
|
<img id="logo_image" alt="logo" src="/logo" />
|
||||||
<div id="main_content">
|
<div id="main_content">
|
||||||
<div class="cards">
|
<div class="cards">
|
||||||
@@ -51,28 +76,8 @@
|
|||||||
<div class="data-value">{{.Email}}</div>
|
<div class="data-value">{{.Email}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form
|
<form action="/logout" method="POST" style="display: inline-block">
|
||||||
action="/logout"
|
<button class="bottom_button" id="signout_button">
|
||||||
method="POST"
|
|
||||||
style="
|
|
||||||
color: var(--primary-accent);
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-top: 20px;
|
|
||||||
display: inline-block;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
style="
|
|
||||||
background: none;
|
|
||||||
border-style: none;
|
|
||||||
color: var(--primary-accent);
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 20px;
|
|
||||||
"
|
|
||||||
id="signout_button"
|
|
||||||
>
|
|
||||||
<input
|
<input
|
||||||
id="csrf_token_storage"
|
id="csrf_token_storage"
|
||||||
type="hidden"
|
type="hidden"
|
||||||
@@ -82,6 +87,16 @@
|
|||||||
Sign Out
|
Sign Out
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<button class="bottom_button" id="change_password_button">
|
||||||
|
<input
|
||||||
|
id="csrf_token_storage"
|
||||||
|
type="hidden"
|
||||||
|
name="csrf_token"
|
||||||
|
value="{{.CSRFToken}}"
|
||||||
|
/>
|
||||||
|
Change Password
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -95,10 +110,76 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
const popup_botton = document.getElementById("change_password_button");
|
||||||
|
|
||||||
|
popup_botton.addEventListener("click", () => {
|
||||||
|
document.getElementById("popup_background").classList.remove("hidden");
|
||||||
|
document
|
||||||
|
.getElementById("change_password_dialouge")
|
||||||
|
.classList.remove("hidden");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
const changePasswordButton = document.getElementById(
|
||||||
|
"final_change_password_button",
|
||||||
|
);
|
||||||
|
|
||||||
|
function displayError(errorText) {
|
||||||
|
document.getElementById("password_error").classList.remove("hidden");
|
||||||
|
document.getElementById("password_text").innerText =
|
||||||
|
"⚠️ " + errorText + ".";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
changePasswordButton.addEventListener("click", () => {
|
||||||
|
if (document.getElementById("current_password").value == "") {
|
||||||
|
displayError("Please enter current password");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
document.getElementById("new_password").value !=
|
||||||
|
document.getElementById("new_password_repeat").value
|
||||||
|
) {
|
||||||
|
displayError("New password and new password repeat do not match");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.getElementById("new_password").value == "") {
|
||||||
|
document
|
||||||
|
.getElementById("password_error")
|
||||||
|
.classList.remove("hidden");
|
||||||
|
displayError("No value for new password");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.getElementById("new_password_repeat").value == "") {
|
||||||
|
displayError("Please repeat new password");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append(
|
||||||
|
"csrf_token",
|
||||||
|
document.getElementById("csrf_token_storage").value,
|
||||||
|
);
|
||||||
|
formData.append("old", file);
|
||||||
|
|
||||||
|
document
|
||||||
|
.getElementById("change_password_dialouge")
|
||||||
|
.classList.add("hidden");
|
||||||
|
document.getElementById("popup_background").classList.add("hidden");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var currentPreviewURL = null;
|
var currentPreviewURL = null;
|
||||||
|
|
||||||
fileInput.addEventListener("change", async () => {
|
fileInput.addEventListener("change", async () => {
|
||||||
|
document.getElementById("popup_background").classList.remove("hidden");
|
||||||
|
|
||||||
const file = fileInput.files[0];
|
const file = fileInput.files[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
if (file.type !== "image/jpeg") {
|
if (file.type !== "image/jpeg") {
|
||||||
@@ -118,7 +199,9 @@
|
|||||||
credentials: "include",
|
credentials: "include",
|
||||||
});
|
});
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
// show the picture (so we don't need to re render the whole page)
|
|
||||||
|
document.getElementById("popup_background").classList.add("hidden");
|
||||||
|
|
||||||
const img = document.querySelector(".profile-pic");
|
const img = document.querySelector(".profile-pic");
|
||||||
|
|
||||||
if (currentPreviewURL != null) {
|
if (currentPreviewURL != null) {
|
||||||
@@ -129,3 +212,5 @@
|
|||||||
currentPreviewURL = img.src;
|
currentPreviewURL = img.src;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script src="/static/error/error.js" type="text/javascript"></script>
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
255,
|
255,
|
||||||
255,
|
255,
|
||||||
255,
|
255,
|
||||||
0.8
|
1
|
||||||
); /* Semi-transparent white for light theme */
|
); /* Semi-transparent white for light theme */
|
||||||
border: 1px solid var(--border-subtle);
|
border: 1px solid var(--border-subtle);
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
padding: 24px;
|
padding: 2.5rem;
|
||||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
|
||||||
transition: transform 0.2s ease;
|
transition: transform 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|||||||
29
static/error/error.css
Normal file
29
static/error/error.css
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
.error {
|
||||||
|
background-color: var(--error-red) !important;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 20px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: var(--error-border-red);
|
||||||
|
border-width: 1px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 12px;
|
||||||
|
position: relative;
|
||||||
|
color: white;
|
||||||
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.close_error_button {
|
||||||
|
position: absolute !important;
|
||||||
|
background-color: rgba(0, 0, 0, 0) !important;
|
||||||
|
padding: 0px !important;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
color: black !important;
|
||||||
|
font-weight: normal !important;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close_error_button:hover {
|
||||||
|
cursor: default;
|
||||||
|
font-weight: bold !important;
|
||||||
|
}
|
||||||
7
static/error/error.js
Normal file
7
static/error/error.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
var error_close_buttons = document.getElementsByClassName("close_error_button");
|
||||||
|
|
||||||
|
for (const close_button of error_close_buttons) {
|
||||||
|
close_button.addEventListener("click", function () {
|
||||||
|
this.parentElement.classList.add("hidden");
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -15,42 +15,13 @@
|
|||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%) translateY(-50%);
|
transform: translateX(-50%) translateY(-50%);
|
||||||
|
|
||||||
background-color: var(--bg-card);
|
|
||||||
border: 1px solid var(--border-subtle);
|
|
||||||
padding: 2.5rem;
|
|
||||||
border-radius: 8px;
|
|
||||||
width: 350px;
|
width: 350px;
|
||||||
|
|
||||||
/* Soft shadow for depth in light mode */
|
|
||||||
box-shadow:
|
|
||||||
0 4px 12px rgba(0, 0, 0, 0.05),
|
|
||||||
0 1px 3px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#login_card input {
|
#login_card input {
|
||||||
padding: 12px;
|
|
||||||
background-color: var(--bg-input);
|
|
||||||
border: 1px solid var(--border-subtle);
|
|
||||||
color: var(--text-main);
|
|
||||||
border-radius: 6px;
|
|
||||||
width: 324px;
|
width: 324px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#login_card input::placeholder {
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
#login_card button {
|
|
||||||
padding: 12px;
|
|
||||||
background-color: var(--primary-accent); /* Our Teal/Blue */
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
#login_card div {
|
#login_card div {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
@@ -69,10 +40,6 @@
|
|||||||
flex: 2;
|
flex: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#login_card button:hover {
|
|
||||||
background-color: var(--primary-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.login_text {
|
.login_text {
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -85,32 +52,3 @@
|
|||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#incorrect_password_text {
|
|
||||||
background-color: var(--error-red) !important;
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 20px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: var(--error-border-red);
|
|
||||||
border-width: 1px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
font-size: 12px;
|
|
||||||
position: relative;
|
|
||||||
color: white;
|
|
||||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#incorrect_password_close_button {
|
|
||||||
position: absolute !important;
|
|
||||||
background-color: rgba(0, 0, 0, 0) !important;
|
|
||||||
padding: 0px !important;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
color: black !important;
|
|
||||||
font-weight: normal !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#incorrect_password_close_button:hover {
|
|
||||||
cursor: default;
|
|
||||||
font-weight: bold !important;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -100,6 +100,21 @@
|
|||||||
line-height: 0;
|
line-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#signout_button:hover {
|
.bottom_button:hover {
|
||||||
text-decoration: underline !important;
|
text-decoration: underline !important;
|
||||||
|
background: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom_button {
|
||||||
|
background: none;
|
||||||
|
border-style: none;
|
||||||
|
color: var(--primary-accent);
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#change_password_dialouge {
|
||||||
|
z-index: 10000;
|
||||||
|
position: fixed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,44 @@ body {
|
|||||||
background-color: var(--bg-main);
|
background-color: var(--bg-main);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
padding: 12px;
|
||||||
|
background-color: var(--primary-accent); /* Our Teal/Blue */
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background-color: var(--primary-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
padding: 12px;
|
||||||
|
background-color: var(--bg-input);
|
||||||
|
border: 1px solid var(--border-subtle);
|
||||||
|
color: var(--text-main);
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::placeholder {
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.blocked {
|
||||||
|
position: fixed; /* or absolute */
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 9999; /* higher = on top */
|
||||||
|
|
||||||
|
background-color: black;
|
||||||
|
opacity: 10%;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user