Created
August 21, 2019 12:43
-
-
Save chelovekula/0f6f9474a1285aa1a110edeca590e81a to your computer and use it in GitHub Desktop.
api-h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.post("/api/buy_fb_accounts", async (req, res) => { | |
let auth = req.headers.authorization; | |
let ip = req.connection.remoteAddress; | |
let n = req.body.n; | |
let set_login = req.body.set_login; | |
if (auth = "SUPER-PASSWORD - SHOW IN TELEGRAM") { | |
const collection = req.app.locals.fbAccounts; | |
let before = collection.count({username: set_login}); | |
let i = n; | |
while ( i-- ) { | |
collection.update({username : ""},{$set:{username: set_login}}, {upsert:false, multi:false}) | |
} | |
let after = collection.count({username: set_login}); | |
if (n == after - before) { | |
res.send({result: true}); | |
console.log("Set " + n + " FB accounts for " + set_login + " in " + Date() + " ip address " + ip); | |
} else { | |
return console.log('error'); | |
} | |
} else { | |
res.send('need_auth'); | |
console.log("Failed to access api(save_user_profile), need_auth " + Date() + " ip address " + ip); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment