diff --git a/chat.css b/chat.css index 27167d8..a66c822 100644 --- a/chat.css +++ b/chat.css @@ -10,6 +10,7 @@ form { } input { + margin-top: 1%; padding: 2%; width: 100%; background-color: darkgrey; diff --git a/chat.js b/chat.js index 447f995..fb61f3b 100644 --- a/chat.js +++ b/chat.js @@ -12,6 +12,7 @@ form.addEventListener("submit", async function (event) { formMessage = formData.get('message').toString(); + //KINDA UNNECESSARY //CHECKS TO SEE IF THE PERSON IS LOGGED IN IN ORDER TO SEND A MESSAGE. const response = await fetch(`api/token/${username}/`); const matches = await response.json(); @@ -75,11 +76,10 @@ function printText(text) { //LOGGED IN STUFF //TODO ADD CHECK TO SEE IF USERNAME AND TOKEN MATCHES function loggedIn() { - username = localStorage.getItem('username'); - if (username === null) { + if (username === '' || username === null) { document.querySelector("#loggeduser").innerHTML = 'You are not logged in' } else { - document.querySelector("#loggeduser").innerHTML = `You are logged in as ${username}` + document.querySelector("#loggeduser").innerHTML = `You are logged in as "${username}"` } } diff --git a/login.js b/login.js index 6584e8d..67190da 100644 --- a/login.js +++ b/login.js @@ -48,10 +48,10 @@ async function loginFetch() { // FUNCTIONS FOR WHETHER THE LOGIN WAS A SUCCESS OR FAILURE function login() { - window.location.replace("/index.html") document.querySelector("#errormessage").innerHTML = '' localStorage.setItem('username', `${uname}`); document.querySelector("#username").innerHTML = `Logged in as ${uname}` + window.location.replace("/index.html") } function incorrectLogin() {