summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranonymous2022-09-21 12:46:08 -0400
committeranonymous2022-09-21 12:46:08 -0400
commit33a84bb2acf9626fa86c2c165b91b66a718e1526 (patch)
tree4d97e686103ff688a558553ee507927c2e88ab50
parent8ca207d31ef3eb9c3102f7fdb23f85b53d16924f (diff)
log in is now just a toggle function, no loggedIn bool
-rw-r--r--auth.js (renamed from src/auth.js)9
-rw-r--r--graffiti.js (renamed from src/socket.js)6
-rw-r--r--utils.js (renamed from src/utils.js)0
3 files changed, 8 insertions, 7 deletions
diff --git a/src/auth.js b/auth.js
index 76cb554..108b42a 100644
--- a/src/auth.js
+++ b/auth.js
@@ -30,6 +30,9 @@ export default {
let myID = window.localStorage.getItem('graffitiID')
if (!token || !myID) {
+ // Remove them both in case one exists
+ // and the other does not
+ token = myID = null
// Check to see if we are redirecting back
const url = new URL(window.location)
@@ -87,7 +90,7 @@ export default {
myID = data.owner_id
// And make sure that the token is valid
- if (!token) {
+ if (!token || !myID) {
throw new Error(`The authorization token could not be parsed from the response.\n\n${data}`)
}
@@ -97,9 +100,7 @@ export default {
}
}
- const loggedIn = (token != null) && (myID != null)
-
- return { loggedIn, myID, token }
+ return { myID, token }
},
diff --git a/src/socket.js b/graffiti.js
index 06cd7c6..7a9c168 100644
--- a/src/socket.js
+++ b/graffiti.js
@@ -39,10 +39,10 @@ export default class {
}
// authorization functions
- logIn() { Auth.logIn(this.graffitiURL) }
- logOut() { Auth.logOut() }
get myID() { return this.authParams.myID }
- get loggedIn() { return this.authParams.loggedIn }
+ toggleLogIn() {
+ this.myID? Auth.logOut() : Auth.logIn(this.graffitiURL)
+ }
async onClose() {
this.open = false
diff --git a/src/utils.js b/utils.js
index ed21d46..ed21d46 100644
--- a/src/utils.js
+++ b/utils.js