mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
some simple bug fix
This commit is contained in:
1 parent
d2173eeb38
commit
d7c9b695b0
6 files changed
+55
-28
No files matched your search
+12
-2
@@ -13,6 +13,12 @@ const {
|
||||
|
||||
class UserLoginHandler extends Handler {
|
||||
async get() {
|
||||
const [loginWithGithub, loginWithGoogle] = await system.getMany(
|
||||
['oauth.githubappid', 'oauth.googleappid'],
|
||||
);
|
||||
this.response.body = {
|
||||
loginWithGithub, loginWithGoogle,
|
||||
};
|
||||
this.response.template = 'user_login.html';
|
||||
}
|
||||
|
||||
@@ -187,13 +193,15 @@ class OauthHandler extends Handler {
|
||||
|
||||
class OauthCallbackHandler extends Handler {
|
||||
async github({ state, code }) {
|
||||
const [appid, secret, url, s] = await Promise.all([
|
||||
const [appid, secret, url, proxy, s] = await Promise.all([
|
||||
system.get('oauth.githubappid'),
|
||||
system.get('oauth.githubsecret'),
|
||||
system.get('server.url'),
|
||||
system.get('proxy'),
|
||||
token.get(state, token.TYPE_OAUTH),
|
||||
]);
|
||||
const res = await superagent.post('https://github.com/login/oauth/access_token')
|
||||
.proxy(proxy)
|
||||
.send({
|
||||
client_id: appid,
|
||||
client_secret: secret,
|
||||
@@ -209,9 +217,11 @@ class OauthCallbackHandler extends Handler {
|
||||
}
|
||||
const t = res.body.access_token;
|
||||
const userInfo = await superagent.get('https://api.github.com/user')
|
||||
.proxy(proxy)
|
||||
.set('User-Agent', 'Hydro-OAuth')
|
||||
.set('Authorization', `token ${t}`);
|
||||
const ret = {
|
||||
email: userInfo.body.mail,
|
||||
email: userInfo.body.email,
|
||||
bio: userInfo.body.bio,
|
||||
uname: [userInfo.body.name, userInfo.body.login],
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user