Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit ac00258

Browse files
authored
Merge pull request #12 from RayhanADev/RayhanADev-Is-Authenticated
Add an In Authenticated Method to Gather Info for Logged In Users
2 parents ca88fb6 + fd0e890 commit ac00258

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/classes/Misc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ class Misc {
3838
}
3939
}
4040
}
41+
42+
async isAuthenticated() {
43+
if (!global.cookies) {
44+
throw new Error('Not logged in.');
45+
} else {
46+
headers.Cookie = global.cookies;
47+
let info = await variables
48+
.fetch('https://staging.repl.it/is_authenticated', {
49+
method: 'GET',
50+
headers
51+
}).then(res => res.json());
52+
53+
if (!info) {
54+
throw new Error(`Cannot fetch authentication data.`);
55+
} else {
56+
return info;
57+
}
58+
}
59+
}
4160
}
4261

4362
module.exports = {

0 commit comments

Comments
 (0)