add logout button to user page
This commit is contained in:
parent
824eb99851
commit
b41d420ce1
@ -54,6 +54,12 @@ function setCookie(cname, cvalue, exdays) {
|
|||||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function logout() {
|
||||||
|
localStorage.setItem("priv_key","")
|
||||||
|
localStorage.setItem("decryption_key","")
|
||||||
|
location.assign('/logout')
|
||||||
|
}
|
||||||
|
|
||||||
async function setuser() {
|
async function setuser() {
|
||||||
if(getCookie("priv_key") != "") {
|
if(getCookie("priv_key") != "") {
|
||||||
localStorage.setItem("priv_key",getCookie("priv_key"))
|
localStorage.setItem("priv_key",getCookie("priv_key"))
|
||||||
|
@ -701,6 +701,11 @@ router.get("/avatars/*", (request, response, next) => {
|
|||||||
response.status(404).send("No avatar with that name found")
|
response.status(404).send("No avatar with that name found")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.get("/logout",async function(req,res) {
|
||||||
|
res.cookie("AUTH_COOKIE","", { maxAge: 0, httpOnly: true, secure: DID_I_FINALLY_ADD_HTTPS })
|
||||||
|
res.redirect("/")
|
||||||
|
})
|
||||||
|
|
||||||
router.get("/*", (request, response, next) => {
|
router.get("/*", (request, response, next) => {
|
||||||
if(!increaseUSERCall(request,response))return
|
if(!increaseUSERCall(request,response))return
|
||||||
let originalUrl = request.originalUrl.split("?").shift()
|
let originalUrl = request.originalUrl.split("?").shift()
|
||||||
@ -719,8 +724,6 @@ router.get("/*", (request, response, next) => {
|
|||||||
response.status(404).send("No file with that name found")
|
response.status(404).send("No file with that name found")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
router.post("/register",async function(req,res) {
|
router.post("/register",async function(req,res) {
|
||||||
for (let i = 0; i < 10; i++) { //don't want people spam registering
|
for (let i = 0; i < 10; i++) { //don't want people spam registering
|
||||||
if(!increaseAPICall(req,res))return;
|
if(!increaseAPICall(req,res))return;
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
<button onclick="location.assign('/changeUsername')">Want to change your username?</button>
|
<button onclick="location.assign('/changeUsername')">Want to change your username?</button>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="location.assign('/posts')">Want to chat with some cool fellas?</button>
|
<button onclick="location.assign('/posts')">Want to chat with some cool fellas?</button>
|
||||||
|
<br>
|
||||||
|
<button onclick="logout()">Logout</button>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user