summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortheia2022-08-02 12:19:41 -0400
committertheia2022-08-02 12:19:41 -0400
commit3e22139af5b2bb312cfbe6771316be64f433035a (patch)
tree4d97e686103ff688a558553ee507927c2e88ab50
parentf8adb58097591481873afac85e7ba011b26adfb0 (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