From db6c5aa2a3c6ad827ebc87799f7c6e6773f6f041 Mon Sep 17 00:00:00 2001 From: Evan Cassidy Date: Mon, 6 Nov 2023 13:46:39 +0000 Subject: [PATCH 01/32] Getting started on the second part of ssh recovery --- src/recovery/ssh-request.html | 215 ++++++++++++++++++++++------------ 1 file changed, 139 insertions(+), 76 deletions(-) diff --git a/src/recovery/ssh-request.html b/src/recovery/ssh-request.html index 3778d9a..c4f8b88 100644 --- a/src/recovery/ssh-request.html +++ b/src/recovery/ssh-request.html @@ -1,86 +1,149 @@ - - - - - Account Recovery - - - - -
- -
-

SSH key recovery

-

- Recover a legacy skynet account using your username and set a new email address to link to the account. Use this only if you do not remember the account password and the linked account email is lost or incorrect.
Enter skynet username & email you have used with UL Wolves.
-

+ + + Account Recovery + + + + +
+ +
+

SSH key recovery

+

In a terminal or windows command prompt run +
echo | ssh-keygen -Y sign -n file -f /path/to/private/key +

With one of the following keys +

+

+ + + + + + + + + + + + +
+
+ +

+
+

SSH key recovery

+

+ Recover a legacy skynet account using your username and set a new email address to link to the account. Use this only if you do not remember the account password and the linked account email is lost or incorrect.
Enter skynet username & email you have used with UL Wolves.
+

- function json(temp) { - if (temp) { - if (temp.result === 'error') { - document.getElementById('formStatus').innerHTML = `${temp.error}`; - } else { - document.getElementById('formStatus').innerHTML = "Success"; - } +
+ + + + + + + + + + + + +


+
+

Success

+ -
-
- UL Computer Society 2023-2023 - -
-
- - \ No newline at end of file + } + +
+
+ UL Computer Society 2023-2023 + +
+
+ + \ No newline at end of file From 1e2d2c0408810e0e26cde707d96018133c61360c Mon Sep 17 00:00:00 2001 From: daragh Date: Sun, 24 Dec 2023 22:15:06 +0000 Subject: [PATCH 02/32] feat : added frontend for getting ssh keys --- src/ssh.html | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/ssh.html diff --git a/src/ssh.html b/src/ssh.html new file mode 100644 index 0000000..879ad51 --- /dev/null +++ b/src/ssh.html @@ -0,0 +1,90 @@ + + + + + SSH + + + + +
+ +
+

SSH

+

+ Add / Remove SSH Keys from your account. +

+ Enter Username and Password to see your current keys. +

+
+ + + + + + + + + + + + +


+
+

+ + +
+
+ UL Computer Society 2023-2023 + +
+
+ + From ec5ecd504c26927b3b5a9c7195e67cbc38f8e9c2 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Wed, 27 Dec 2023 14:47:29 +0000 Subject: [PATCH 03/32] feat: adjust any form that takes teh suers username and pass so its in the auth field. Closes #8 --- src/modify.html | 2 +- src/password.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modify.html b/src/modify.html index 7a7220a..6bf131a 100644 --- a/src/modify.html +++ b/src/modify.html @@ -62,7 +62,7 @@ const user = formData.get("user"); const pass = formData.get("pass"); const value = formData.get("value"); - const object = {user: user, pass: pass, field: field, value: value} + const object = {auth: {user: user, pass: pass}, field: field, value: value} fetch('https://api.account.skynet.ie/ldap/update', { method: 'POST', body: JSON.stringify(object), diff --git a/src/password.html b/src/password.html index 9b53099..9a7e389 100644 --- a/src/password.html +++ b/src/password.html @@ -52,7 +52,7 @@ const pass = formData.get("pass"); const newPW = formData.get("newPW"); if (newPW === formData.get("newPWConfirm")) { - const object = {user: user, pass: pass, field: "userPassword", value: newPW} + const object = {auth: {user: user, pass: pass}, field: "userPassword", value: newPW} fetch('https://api.account.skynet.ie/ldap/update', { method: 'POST', body: JSON.stringify(object), From 115f0257e5a914abc48bceb9c490e218c3a49525 Mon Sep 17 00:00:00 2001 From: daragh Date: Sat, 30 Dec 2023 01:47:41 +0000 Subject: [PATCH 04/32] feat : frontend for adding & deleting keys --- src/scripts/ssh.js | 127 ++++++++++++++++++++++++++++++++++++++++++++ src/ssh.html | 128 ++++++++++++++++++++------------------------- 2 files changed, 185 insertions(+), 70 deletions(-) create mode 100644 src/scripts/ssh.js diff --git a/src/scripts/ssh.js b/src/scripts/ssh.js new file mode 100644 index 0000000..b791691 --- /dev/null +++ b/src/scripts/ssh.js @@ -0,0 +1,127 @@ +let got_keys = false; + +function get_keys() { + console.log("get_keys running , got_keys = ", got_keys); + let username = document.getElementById("user").value; + let password = document.getElementById("pass").value; + let request = {auth: {user: username, pass: password}}; + + fetch('http://127.0.0.1:8087/ldap/ssh', { + method: 'POST', + body: JSON.stringify(request), + mode: 'cors', + }).then(res => { + if (res.status === 200) { + return res.json(); + } else { + document.getElementById('formStatus').innerHTML = "Failed to fetch"; + } + }).then(data => { + if (data.result === "success") { + document.getElementById('formStatus').innerHTML = "Success : Got keys"; + let keys = data.success; + document.getElementById('key_table').style.display = "table"; + got_keys = true; + keys.forEach(key => { + add_to_table(key); + }) + } else { + document.getElementById('formStatus').innerHTML = "Failed to get keys"; + } + }).catch(err => { + console.log(err); + }); +} + +function add_key() { + let username = document.getElementById("user").value; + let password = document.getElementById("pass").value; + let key = document.getElementById("key_input").value; + let request = {auth: {user: username, pass: password}, key: key}; + if (key === "") { + document.getElementById('formStatus').innerHTML = "Key cannot be empty"; + return; + } + fetch('http://127.0.0.1:8087/ldap/add', { + method: 'POST', + body: JSON.stringify(request), + mode: 'cors', + }).then(res => { + if (res.status === 200) { + return res.json(); + } else { + document.getElementById('formStatus').innerHTML = "Failed to fetch"; + } + + }).then(data => { + if (data.result === "success") { + document.getElementById('formStatus').innerHTML = "Success : Key added"; + document.getElementById('key_table').style.display = "table"; + add_to_table(key); + } else { + document.getElementById('formStatus').innerHTML = "Failed to add"; + } + }).catch(err => { + document.getElementById('formStatus').innerHTML = "Error "; + console.log(err); + }); +} + +function delete_key(row_idx) { + let table = document.getElementById("key_table"); + let key = table.rows[row_idx].cells[0].innerHTML; + let username = document.getElementById("user").value; + let password = document.getElementById("pass").value; + let request = {auth: {user: username, pass: password}, key: key}; + + fetch('http://127.0.0.1:8087/ldap/delete', { + method: 'DELETE', + body: JSON.stringify(request), + mode: 'cors', + }).then(res => { + if (res.status === 200) { + return res.json(); + } else { + document.getElementById('formStatus').innerHTML = "Failed to fetch"; + } + }).then(data => { + if (data.result === "success") { + table.deleteRow(row_idx); + document.getElementById('formStatus').innerHTML = "Success : Key deleted"; + } else { + document.getElementById('formStatus').innerHTML = "Failed to delete"; + } + }).catch(err => { + document.getElementById('formStatus').innerHTML = "Error "; + console.log(err); + }) +} + +function add_to_table(key) { + let table = document.getElementById("key_table"); + let row = table.insertRow(); + let cell1 = row.insertCell(0); + cell1.innerHTML = key; + let cell2 = row.insertCell(1); + + let button = document.createElement("button"); + button.innerHTML = "Delete"; + cell2.appendChild(button); + //cell2.appendChild(document.createElement("button")).innerHTML = "Delete"; + button.addEventListener("click", function () { + delete_key(row.rowIndex); + }); +} + +document.addEventListener("DOMContentLoaded", () => { + document.getElementById("get_keys").addEventListener("click", function () { + if (got_keys) { + console.log("got keys already"); + document.getElementById('formStatus').innerHTML = "Got keys already"; + } else { + get_keys(); + } + }); + document.getElementById("add_key_button").addEventListener("click", add_key); +}); + diff --git a/src/ssh.html b/src/ssh.html index 879ad51..be524f3 100644 --- a/src/ssh.html +++ b/src/ssh.html @@ -1,90 +1,78 @@ - + SSH - - -
- +

SSH

- Add / Remove SSH Keys from your account. -

- Enter Username and Password to see your current keys. + Add / Remove SSH Keys from your account.

- - - - - - - - - - - - -


+ + + + + + + + + + + + +


+ +

- - -
-
+ + + + + + + +
KeyRemove
+ + +
UL Computer Society 2023-2023 -
-
- + + + From 0af81c6efa79522abbdce86942aea13f738cffb0 Mon Sep 17 00:00:00 2001 From: daragh Date: Sat, 30 Dec 2023 01:55:45 +0000 Subject: [PATCH 05/32] fix : fetch paths --- src/scripts/ssh.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scripts/ssh.js b/src/scripts/ssh.js index b791691..b4ec2dd 100644 --- a/src/scripts/ssh.js +++ b/src/scripts/ssh.js @@ -7,6 +7,7 @@ function get_keys() { let request = {auth: {user: username, pass: password}}; fetch('http://127.0.0.1:8087/ldap/ssh', { + // can switch this to get with auth headers i think method: 'POST', body: JSON.stringify(request), mode: 'cors', @@ -42,7 +43,7 @@ function add_key() { document.getElementById('formStatus').innerHTML = "Key cannot be empty"; return; } - fetch('http://127.0.0.1:8087/ldap/add', { + fetch('http://127.0.0.1:8087/ldap/ssh/add', { method: 'POST', body: JSON.stringify(request), mode: 'cors', @@ -74,7 +75,7 @@ function delete_key(row_idx) { let password = document.getElementById("pass").value; let request = {auth: {user: username, pass: password}, key: key}; - fetch('http://127.0.0.1:8087/ldap/delete', { + fetch('http://127.0.0.1:8087/ldap/ssh', { method: 'DELETE', body: JSON.stringify(request), mode: 'cors', From 7f40a4b259cea66884a8508a88b8faa667af4847 Mon Sep 17 00:00:00 2001 From: daragh Date: Sat, 30 Dec 2023 04:07:35 +0000 Subject: [PATCH 06/32] feat : added link to SSH page from main page Might also need to remove SSH stuff from modify page --- src/index.html | 94 +++++++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/src/index.html b/src/index.html index e1faf23..91bb0fa 100644 --- a/src/index.html +++ b/src/index.html @@ -1,65 +1,73 @@ - + Skynet Self Service - - -
- +
-

- Sign-up -

-

- Please use this if you have yet to activate an account on Skynet before. -

+

+ Sign-up +

+

+ Please use this if you have yet to activate an account on Skynet before. +

-

- Change Password -

-

- Please use this service to change your Skynet password -

+

+ Change Password +

+

+ Please use this service to change your Skynet password. +

-

- Account modification -

-

- Please use this service to modify your user data (email, login ssh key, etc.) -

+

+ Account modification +

+

+ Please use this service to modify your user data (email, login ssh key, etc.). +

-

- Forgot your username? -

-

- Please use this service to get a reminder email with your Skynet username -

+

+ Forgot your username? +

+

+ Please use this service to get a reminder email with your Skynet username. +

-

- Forgot your password? -

-

- Please use this service to reset your password. -

+

+ Forgot your password? +

+

+ Please use this service to reset your password. +

-
-
+
+

+ SSH +

+

+ Please use this service to manage your SSH keys. +

+
+ +
UL Computer Society 2023-2023 -
-
- + + + \ No newline at end of file From 128794648c3b918f068962cb4a48330b5a2e04df Mon Sep 17 00:00:00 2001 From: daragh Date: Sat, 30 Dec 2023 23:27:32 +0000 Subject: [PATCH 07/32] feat : made input for new key textarea, split keys on their comment to display in table. Made js code use async/await instead of then. Works fine with mockoon but might need more testing with actual LDAP server. --- src/index.html | 2 +- src/scripts/ssh.js | 128 ----------------------------- src/{ssh.html => ssh/index.html} | 27 ++++--- src/ssh/ssh.js | 134 +++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+), 138 deletions(-) delete mode 100644 src/scripts/ssh.js rename src/{ssh.html => ssh/index.html} (68%) create mode 100644 src/ssh/ssh.js diff --git a/src/index.html b/src/index.html index 91bb0fa..aaa5fcd 100644 --- a/src/index.html +++ b/src/index.html @@ -55,7 +55,7 @@

- SSH + SSH

Please use this service to manage your SSH keys. diff --git a/src/scripts/ssh.js b/src/scripts/ssh.js deleted file mode 100644 index b4ec2dd..0000000 --- a/src/scripts/ssh.js +++ /dev/null @@ -1,128 +0,0 @@ -let got_keys = false; - -function get_keys() { - console.log("get_keys running , got_keys = ", got_keys); - let username = document.getElementById("user").value; - let password = document.getElementById("pass").value; - let request = {auth: {user: username, pass: password}}; - - fetch('http://127.0.0.1:8087/ldap/ssh', { - // can switch this to get with auth headers i think - method: 'POST', - body: JSON.stringify(request), - mode: 'cors', - }).then(res => { - if (res.status === 200) { - return res.json(); - } else { - document.getElementById('formStatus').innerHTML = "Failed to fetch"; - } - }).then(data => { - if (data.result === "success") { - document.getElementById('formStatus').innerHTML = "Success : Got keys"; - let keys = data.success; - document.getElementById('key_table').style.display = "table"; - got_keys = true; - keys.forEach(key => { - add_to_table(key); - }) - } else { - document.getElementById('formStatus').innerHTML = "Failed to get keys"; - } - }).catch(err => { - console.log(err); - }); -} - -function add_key() { - let username = document.getElementById("user").value; - let password = document.getElementById("pass").value; - let key = document.getElementById("key_input").value; - let request = {auth: {user: username, pass: password}, key: key}; - if (key === "") { - document.getElementById('formStatus').innerHTML = "Key cannot be empty"; - return; - } - fetch('http://127.0.0.1:8087/ldap/ssh/add', { - method: 'POST', - body: JSON.stringify(request), - mode: 'cors', - }).then(res => { - if (res.status === 200) { - return res.json(); - } else { - document.getElementById('formStatus').innerHTML = "Failed to fetch"; - } - - }).then(data => { - if (data.result === "success") { - document.getElementById('formStatus').innerHTML = "Success : Key added"; - document.getElementById('key_table').style.display = "table"; - add_to_table(key); - } else { - document.getElementById('formStatus').innerHTML = "Failed to add"; - } - }).catch(err => { - document.getElementById('formStatus').innerHTML = "Error "; - console.log(err); - }); -} - -function delete_key(row_idx) { - let table = document.getElementById("key_table"); - let key = table.rows[row_idx].cells[0].innerHTML; - let username = document.getElementById("user").value; - let password = document.getElementById("pass").value; - let request = {auth: {user: username, pass: password}, key: key}; - - fetch('http://127.0.0.1:8087/ldap/ssh', { - method: 'DELETE', - body: JSON.stringify(request), - mode: 'cors', - }).then(res => { - if (res.status === 200) { - return res.json(); - } else { - document.getElementById('formStatus').innerHTML = "Failed to fetch"; - } - }).then(data => { - if (data.result === "success") { - table.deleteRow(row_idx); - document.getElementById('formStatus').innerHTML = "Success : Key deleted"; - } else { - document.getElementById('formStatus').innerHTML = "Failed to delete"; - } - }).catch(err => { - document.getElementById('formStatus').innerHTML = "Error "; - console.log(err); - }) -} - -function add_to_table(key) { - let table = document.getElementById("key_table"); - let row = table.insertRow(); - let cell1 = row.insertCell(0); - cell1.innerHTML = key; - let cell2 = row.insertCell(1); - - let button = document.createElement("button"); - button.innerHTML = "Delete"; - cell2.appendChild(button); - //cell2.appendChild(document.createElement("button")).innerHTML = "Delete"; - button.addEventListener("click", function () { - delete_key(row.rowIndex); - }); -} - -document.addEventListener("DOMContentLoaded", () => { - document.getElementById("get_keys").addEventListener("click", function () { - if (got_keys) { - console.log("got keys already"); - document.getElementById('formStatus').innerHTML = "Got keys already"; - } else { - get_keys(); - } - }); - document.getElementById("add_key_button").addEventListener("click", add_key); -}); - diff --git a/src/ssh.html b/src/ssh/index.html similarity index 68% rename from src/ssh.html rename to src/ssh/index.html index be524f3..955f38f 100644 --- a/src/ssh.html +++ b/src/ssh/index.html @@ -3,15 +3,25 @@ SSH - - - + + + -

- Account modification + Account modification

Please use this service to modify your user data (email, login ssh key, etc.) diff --git a/src/modify.html b/src/modify.html deleted file mode 100644 index 6bf131a..0000000 --- a/src/modify.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - - Modify Account - - - - -

- -
-

User modification page

-

- Modify details of your Skynet account. -

-
- - - - - - - - - - - - - - - - - - - - -


- -

-
-

- -
-
- UL Computer Society 2023-2023 - -
-
- - \ No newline at end of file diff --git a/src/modify/index.html b/src/modify/index.html new file mode 100644 index 0000000..80f7534 --- /dev/null +++ b/src/modify/index.html @@ -0,0 +1,62 @@ + + + + + Modify Account + + + + +
+ +
+

User modification page

+

+ Modify details of your Skynet account. +

+
+ + + + + + + + + + + + + + + + + + + + +


+ +

+
+

+ +
+
+ UL Computer Society 2023-2023 + +
+
+ + \ No newline at end of file diff --git a/src/modify/modify.js b/src/modify/modify.js new file mode 100644 index 0000000..131dc80 --- /dev/null +++ b/src/modify/modify.js @@ -0,0 +1,58 @@ +const form = document.getElementById("form"); +form.addEventListener('submit', formHandler); + +const button = document.getElementById("button"); +button.addEventListener('submit', formHandler); + +const dropdown = document.getElementById("dropdown"); +dropdown.addEventListener('onchange', selectField); + +async function formHandler(listener) { + listener.preventDefault(); + const formData = new FormData(form); + const dropdown_value = dropdown.value; + + if (dropdown_value === "") { + document.getElementById('formStatus').innerHTML = "Please select a field to modify"; + return; + } + + const user = formData.get("user"); + const pass = formData.get("pass"); + const value = formData.get("value"); + const body = {auth: {user: user, pass: pass}, field: dropdown_value, value: value}; + + let url = 'https://api.account.skynet.ie/ldap/update'; + let req; + + try { + req = await fetch(url, { + method: 'POST', + body: JSON.stringify(body), + mode: "cors" + }); + } catch (e) { + document.getElementById('formStatus').innerHTML = `${e}`; + return; + } + + if (req.status !== 200) { + document.getElementById('formStatus').innerHTML = "Failure"; + return; + } + + let temp = await req.json(); + if (temp.result === 'error') { + document.getElementById('formStatus').innerHTML = `${temp.error}`; + } else { + document.getElementById('formStatus').innerHTML = "Success"; + } +} + +function selectField() { + if (dropdown.value === 'mail') { + document.getElementById('value').type = 'email'; + } else { + document.getElementById('value').type = 'text'; + } +} \ No newline at end of file diff --git a/src/recovery/password_reset.html b/src/recovery/password_reset.html index f23f921..753f33f 100644 --- a/src/recovery/password_reset.html +++ b/src/recovery/password_reset.html @@ -73,7 +73,7 @@ return; } - let data = req.json(); + let data = await req.json(); if (data.result === 'error') { document.getElementById('formStatus').innerHTML = `${data.error}`; } else { diff --git a/src/signup.html b/src/signup.html index 6797d51..ae946fe 100644 --- a/src/signup.html +++ b/src/signup.html @@ -36,7 +36,7 @@

Welcome to Skynet

- If you previously had an account please set your email to be the same as UL Wolves. + If you previously had an account please set your email to be the same as UL Wolves.
If you are a new user, please fill in the form below with the email that you use on ul wolves.

From 019d22695f863a8d53c7b2c6f8e8cb32856e4696 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 1 Jan 2024 09:08:07 +0000 Subject: [PATCH 12/32] feat: Moved the JS out of the password reset page into its own file Related to #9 --- src/index.html | 2 +- src/password.html | 83 ---------------------------------------- src/password/index.html | 54 ++++++++++++++++++++++++++ src/password/password.js | 49 ++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 84 deletions(-) delete mode 100644 src/password.html create mode 100644 src/password/index.html create mode 100644 src/password/password.js diff --git a/src/index.html b/src/index.html index e3b815e..d00e122 100644 --- a/src/index.html +++ b/src/index.html @@ -23,7 +23,7 @@

- Change Password + Change Password

Please use this service to change your Skynet password diff --git a/src/password.html b/src/password.html deleted file mode 100644 index 9a7e389..0000000 --- a/src/password.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - Password reset - - - - -

- -
-

Password Change

-

- Change your Skynet password. -

-
- - - - - - - - - - - - - - - - - - - - -




-
-

- -
-
- UL Computer Society 2023-2023 - -
-
- - diff --git a/src/password/index.html b/src/password/index.html new file mode 100644 index 0000000..f6fe8c2 --- /dev/null +++ b/src/password/index.html @@ -0,0 +1,54 @@ + + + + + Password reset + + + + +
+ +
+

Password Change

+

+ Change your Skynet password. +

+
+ + + + + + + + + + + + + + + + + + + + +




+
+

+ +
+
+ UL Computer Society 2023-2023 + +
+
+ + diff --git a/src/password/password.js b/src/password/password.js new file mode 100644 index 0000000..e6cc5f2 --- /dev/null +++ b/src/password/password.js @@ -0,0 +1,49 @@ +const form = document.getElementById("form"); +form.addEventListener('submit', formHandler); + +const form_status = document.getElementById("formStatus"); + +const button = document.getElementById("button"); +button.addEventListener('submit', formHandler); + +async function formHandler(listener) { + listener.preventDefault(); + const formData = new FormData(form); + const user = formData.get("user"); + const pass = formData.get("pass"); + const newPW = formData.get("newPW"); + if (newPW !== formData.get("newPWConfirm")) { + + document.getElementById('formStatus').innerHTML = "Failure: new passwords don't match"; + + return; + } + + const body = {auth: {user: user, pass: pass}, field: "userPassword", value: newPW} + + let url = 'https://api.account.skynet.ie/ldap/update'; + let req; + + try { + req = await fetch(url, { + method: 'POST', + body: JSON.stringify(body), + mode: "cors" + }); + } catch (e) { + form_status.innerHTML = `${e}`; + return; + } + + if (req.status !== 200) { + form_status.innerHTML = "Failure"; + return; + } + + let temp = await req.json(); + if (temp.result === 'error') { + form_status.innerHTML = `${temp.error}`; + } else { + form_status.innerHTML = "Success"; + } +} \ No newline at end of file From da7adea36e42b3b09eb25c47a8e4ce4a6e7505d9 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 1 Jan 2024 09:19:04 +0000 Subject: [PATCH 13/32] feat: Moved the JS out of the register page into its own file Related to #9 --- src/register.html | 97 ---------------------------------------- src/register/index.html | 56 +++++++++++++++++++++++ src/register/register.js | 56 +++++++++++++++++++++++ 3 files changed, 112 insertions(+), 97 deletions(-) delete mode 100644 src/register.html create mode 100644 src/register/index.html create mode 100644 src/register/register.js diff --git a/src/register.html b/src/register.html deleted file mode 100644 index e915177..0000000 --- a/src/register.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Skynet Register - - - - -
- -
-

Register

-

- Thank you for signing up for your Skynet account. -
- Please complete the process by filling in the form below. -
- Username is what you want to be known on Skynet as. -
- It must be lowercase, start with a letter and contain only 0-9 a-z and _- -

-
- - - - - - - - - - - - - - - - -


-
-

- -
-
- UL Computer Society 2023-2023 - -
-
- - \ No newline at end of file diff --git a/src/register/index.html b/src/register/index.html new file mode 100644 index 0000000..9cfd259 --- /dev/null +++ b/src/register/index.html @@ -0,0 +1,56 @@ + + + + + Skynet Register + + + + +
+ +
+

Register

+

+ Thank you for signing up for your Skynet account. +
+ Please complete the process by filling in the form below. +
+ Username is what you want to be known on Skynet as. +
+ It must be lowercase, start with a letter and contain only 0-9 a-z and _- +

+
+ + + + + + + + + + + + + + + + +


+
+

+ +
+
+ UL Computer Society 2023-2023 + +
+
+ + \ No newline at end of file diff --git a/src/register/register.js b/src/register/register.js new file mode 100644 index 0000000..2e5f9a8 --- /dev/null +++ b/src/register/register.js @@ -0,0 +1,56 @@ +const form = document.getElementById("form"); +form.addEventListener('submit', formHandler); + +const form_status = document.getElementById("formStatus"); + +const button = document.getElementById("button"); +button.addEventListener('submit', formHandler); + +async function formHandler(listener) { + listener.preventDefault(); + const formData = new FormData(form); + const pass = formData.get("pass"); + + if (pass !== formData.get("confirm")) { + form_status.innerHTML = `Passwords don't match`; + return; + } + + + const urlParam = new URLSearchParams(new URL(window.location.href).search); + const auth = urlParam.get("auth"); + + // if there is no auth value then return here + if(!auth){ + return; + } + + const user = formData.get("user"); + const body = {auth: auth, user: user, pass: pass}; + + let url = 'https://api.account.skynet.ie/ldap/new/account'; + let req; + + try { + req = await fetch(url, { + method: 'POST', + body: JSON.stringify(body), + mode: "cors" + }); + } catch (e) { + form_status.innerHTML = `${e}`; + return; + } + + if (req.status !== 200) { + form_status.innerHTML = "Failure"; + return; + } + + let temp = await req.json(); + if (temp.result === 'error') { + form_status.innerHTML = `${temp.error}`; + } else { + form_status.innerHTML = "Success"; + } +} \ No newline at end of file From 68953f0d5fabf84b21661c64f9074bf1a39e7aa2 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 1 Jan 2024 09:24:48 +0000 Subject: [PATCH 14/32] feat: Moved the JS out of the signup page into its own file Related to #9 --- src/index.html | 2 +- src/signup.html | 84 ------------------------------------------- src/signup/index.html | 59 ++++++++++++++++++++++++++++++ src/signup/signup.js | 45 +++++++++++++++++++++++ 4 files changed, 105 insertions(+), 85 deletions(-) delete mode 100644 src/signup.html create mode 100644 src/signup/index.html create mode 100644 src/signup/signup.js diff --git a/src/index.html b/src/index.html index d00e122..f1acd06 100644 --- a/src/index.html +++ b/src/index.html @@ -15,7 +15,7 @@

- Sign-up + Sign-up

Please use this if you have yet to activate an account on Skynet before. diff --git a/src/signup.html b/src/signup.html deleted file mode 100644 index ae946fe..0000000 --- a/src/signup.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - Skynet Sign-up - - - - - -

- -
-

Welcome to Skynet

-

- If you previously had an account please set your email to be the same as UL Wolves. -
- If you are a new user, please fill in the form below with the email that you use on ul wolves. -

-
- -
- -
-

- -
-
- UL Computer Society 2023-2023 - -
-
- - \ No newline at end of file diff --git a/src/signup/index.html b/src/signup/index.html new file mode 100644 index 0000000..9cb9b5b --- /dev/null +++ b/src/signup/index.html @@ -0,0 +1,59 @@ + + + + + Skynet Sign-up + + + + + +
+ +
+

Welcome to Skynet

+

+ If you previously had an account please set your email to be the same as UL Wolves. +
+ If you are a new user, please fill in the form below with the email that you use on ul wolves. +

+
+ +
+ +
+

+ +
+
+ UL Computer Society 2023-2023 + +
+
+ + \ No newline at end of file diff --git a/src/signup/signup.js b/src/signup/signup.js new file mode 100644 index 0000000..fcd3a50 --- /dev/null +++ b/src/signup/signup.js @@ -0,0 +1,45 @@ +const form = document.getElementById("form"); +form.addEventListener('submit', formHandler); + +const form_status = document.getElementById("formStatus"); + +const button = document.getElementById("button"); +button.addEventListener('submit', formHandler); + +async function formHandler(listener) { + listener.preventDefault(); + //HTML below taken from the W3 schools tutorial () + form_status.innerHTML = "
" + + const formData = new FormData(form); + const email = formData.get("email"); + const body = {email: email}; + + + let url = 'https://api.account.skynet.ie/ldap/new/email'; + let req; + + try { + req = await fetch(url, { + method: 'POST', + body: JSON.stringify(body), + mode: "cors" + }); + } catch (e) { + form_status.innerHTML = `${e}`; + return; + } + + if (req.status !== 200) { + form_status.innerHTML = "Failure"; + return; + } + + let temp = await req.json(); + if (temp.result === 'error') { + form_status.innerHTML = `${temp.error}`; + } else { + form_status.innerHTML = "Success"; + } + +} \ No newline at end of file From ad55bf81efc3ba3b4a3e1b2d46fd96efae8a5d76 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 1 Jan 2024 09:28:22 +0000 Subject: [PATCH 15/32] fix: not going to give these their own folder --- src/index.html | 6 +++--- src/{modify/index.html => modify.html} | 6 +++--- src/{modify => }/modify.js | 0 src/{password/index.html => password.html} | 6 +++--- src/{password => }/password.js | 0 src/{register/index.html => register.html} | 6 +++--- src/{register => }/register.js | 0 src/{signup/index.html => signup.html} | 8 ++++---- src/{signup => }/signup.js | 0 9 files changed, 16 insertions(+), 16 deletions(-) rename src/{modify/index.html => modify.html} (88%) rename src/{modify => }/modify.js (100%) rename src/{password/index.html => password.html} (86%) rename src/{password => }/password.js (100%) rename src/{register/index.html => register.html} (87%) rename src/{register => }/register.js (100%) rename src/{signup/index.html => signup.html} (79%) rename src/{signup => }/signup.js (100%) diff --git a/src/index.html b/src/index.html index f1acd06..5741c3b 100644 --- a/src/index.html +++ b/src/index.html @@ -15,7 +15,7 @@

- Sign-up + Sign-up

Please use this if you have yet to activate an account on Skynet before. @@ -23,7 +23,7 @@

- Change Password + Change Password

Please use this service to change your Skynet password @@ -31,7 +31,7 @@

- Account modification + Account modification

Please use this service to modify your user data (email, login ssh key, etc.) diff --git a/src/modify/index.html b/src/modify.html similarity index 88% rename from src/modify/index.html rename to src/modify.html index 80f7534..f201542 100644 --- a/src/modify/index.html +++ b/src/modify.html @@ -3,13 +3,13 @@ Modify Account - - + +

diff --git a/src/modify/modify.js b/src/modify.js similarity index 100% rename from src/modify/modify.js rename to src/modify.js diff --git a/src/password/index.html b/src/password.html similarity index 86% rename from src/password/index.html rename to src/password.html index f6fe8c2..c719e80 100644 --- a/src/password/index.html +++ b/src/password.html @@ -3,13 +3,13 @@ Password reset - - + +
diff --git a/src/password/password.js b/src/password.js similarity index 100% rename from src/password/password.js rename to src/password.js diff --git a/src/register/index.html b/src/register.html similarity index 87% rename from src/register/index.html rename to src/register.html index 9cfd259..6477b0a 100644 --- a/src/register/index.html +++ b/src/register.html @@ -3,13 +3,13 @@ Skynet Register - - + +
diff --git a/src/register/register.js b/src/register.js similarity index 100% rename from src/register/register.js rename to src/register.js diff --git a/src/signup/index.html b/src/signup.html similarity index 79% rename from src/signup/index.html rename to src/signup.html index 9cb9b5b..35417f1 100644 --- a/src/signup/index.html +++ b/src/signup.html @@ -3,8 +3,8 @@ Skynet Sign-up - - + +
@@ -66,6 +73,7 @@ placeholder="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINS2UR/o+nK8lNHHTj5I84ZAAp6P+ZhXqhedMfx0KHE4 My skynet key!"> +
diff --git a/src/modify_ssh.js b/src/modify_ssh.js index 94dd808..df07a5d 100644 --- a/src/modify_ssh.js +++ b/src/modify_ssh.js @@ -1,13 +1,14 @@ -function update_table(keys){ +function update_table(keys) { let table = document.getElementById("key_table") //removing old table - while(table.rows.length > 0){ + while (table.rows.length > 0) { table.deleteRow(0); } keys.forEach(key => { add_to_table(key); }) } + async function get_keys() { let username = document.getElementById("user").value; let password = document.getElementById("pass").value; @@ -68,7 +69,7 @@ async function add_key() { } } -async function delete_key(row_idx,key) { +async function delete_key(row_idx, key) { let username = document.getElementById("user").value; let password = document.getElementById("pass").value; @@ -102,7 +103,7 @@ async function delete_key(row_idx,key) { function add_to_table(key) { let table = document.getElementById("key_table"); let row = table.insertRow(); - row.setAttribute("ssh_key",key); + row.setAttribute("ssh_key", key); let cell_name = row.insertCell(0); let cell_key = row.insertCell(1); @@ -115,7 +116,7 @@ function add_to_table(key) { for (let i = 2; i < key_split.length; i++) { comment += " " + key_split[i]; } - if(key_split.length === 2) { + if (key_split.length === 2) { comment = "No comment"; } cell_name.textContent = comment; From 71f5928c66a43e788a9a00b90a1326c1bb82ffd2 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Fri, 9 Aug 2024 21:16:59 +0100 Subject: [PATCH 31/32] ci: swapped out gitlab for forgejo actions --- .forgejo/workflows/build.yaml | 28 ++++++++++++++++++++++++++++ .gitlab-ci.yml | 17 ----------------- 2 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 .forgejo/workflows/build.yaml delete mode 100644 .gitlab-ci.yml diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml new file mode 100644 index 0000000..7e37d21 --- /dev/null +++ b/.forgejo/workflows/build.yaml @@ -0,0 +1,28 @@ +name: Build + +on: + push: + branches: + - 'main' + +jobs: + build: + # build it using teh base nixos system, helps with caching + runs-on: nix + steps: + # get the repo first + - uses: https://code.forgejo.org/actions/checkout@v4 + - name: "Build it locally" + run: nix build --verbose + + # deploy it upstream + deploy: + # runs on teh default docker dontainer + runs-on: docker + needs: [ build ] + steps: + - name: "Deploy to Skynet" + uses: https://forgejo.skynet.ie/Skynet/actions-deploy-to-skynet@v2 + with: + input: 'skynet_ldap_frontend' + token: ${{ secrets.API_TOKEN_FORGEJO }} \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 300aaf5..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,17 +0,0 @@ -# from https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html - -# only a deploy stage -stages: - - deploy - - -nixos: - stage: deploy - variables: - PACKAGE_NAME: "skynet_ldap_frontend" - UPDATE_FLAKE: "yes" - trigger: compsoc1/skynet/nixos - only: - refs: - - main - \ No newline at end of file From e09818ca6b27bf98cf63c3427a7253309c39a816 Mon Sep 17 00:00:00 2001 From: esy Date: Mon, 23 Sep 2024 20:07:50 +0000 Subject: [PATCH 32/32] feat: add license --- LICENSE | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3283b25 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 Skynet + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file