-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfunctions.js
More file actions
40 lines (34 loc) · 890 Bytes
/
functions.js
File metadata and controls
40 lines (34 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const Database = require("@replit/database");
const db = new Database();
function loggedIn(req){
return (req.session.username ? true: false);
}
function getUser(req){
return req.session.username;
}
async function is_human(captcha_response){
let secret = process.env["captcha_secret"];
let payload = {response:captcha_response, secret:secret};
let result = await require('axios')({
method:"POST",
url: "https://www.google.com/recaptcha/api/siteverify",
params:payload,
});
return result.data.success;
}
async function getCharacter(user){
let info = await db.get(user);
return info.c;
}
async function setCharacter(user, character){
let info = await db.get(user);
info.c = character;
await db.set(user, info);
}
module.exports = {
loggedIn:loggedIn,
getUser:getUser,
is_human:is_human,
getCharacter:getCharacter,
setCharacter:setCharacter
}