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

Commit

Permalink
add user to list of plus users
Browse files Browse the repository at this point in the history
  • Loading branch information
montyanderson committed Feb 21, 2020
1 parent b8ccdc2 commit bdfc74d
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions server.js
Expand Up @@ -179,6 +179,21 @@ router.get('/worker-stats', async ctx => {
}))), null, "\t")
});

router.post('/login', async ctx => {
const {code} = ctx.query;

const accessToken = await oauth.getAccessToken(code);
const user = await oauth.getUser(accessToken);

console.log(user);

await redis.zadd('plus-users', 'NX', Date.now(), user.login);

ctx.body = JSON.stringify({
user
});
});

router.use('/lock', async (ctx, next) => {
const token = ctx.request.headers['x-worker-token'];

Expand Down Expand Up @@ -211,19 +226,6 @@ router.post('/lock', async ctx => {
ctx.body = JSON.stringify(username);
});

router.post('/login', async ctx => {
const {code} = ctx.query;

const accessToken = await oauth.getAccessToken(code);
const user = await oauth.getUser(accessToken);

console.log(user);

ctx.body = JSON.stringify({
user
});
});

router.post('/lock/:username', async ctx => {
await redis.expire(`lock:${ctx.params.username}`, 10);

Expand Down

0 comments on commit bdfc74d

Please sign in to comment.