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],
|
||||
};
|
||||
|
||||
@@ -78,7 +78,7 @@ AccountSetting(
|
||||
Setting('setting_info', 'bio', null,
|
||||
null, 'markdown', 'Bio'),
|
||||
Setting('setting_customize', 'backgroundImage', null,
|
||||
'/components/background/profile/backgrounds/1.jpg', 'text', 'Profile Background Image',
|
||||
'/components/profile/backgrounds/1.jpg', 'text', 'Profile Background Image',
|
||||
'Choose the background image in your profile page.'),
|
||||
);
|
||||
|
||||
|
||||
+19
-17
@@ -210,23 +210,24 @@ class Handler {
|
||||
this.response.disposition = `attachment; filename="${name}"`;
|
||||
}
|
||||
|
||||
url(name, kwargs = {}) { // eslint-disable-line class-methods-use-this
|
||||
url(name, kwargs = {}) {
|
||||
let res = '#';
|
||||
const args = { ...kwargs };
|
||||
try {
|
||||
delete kwargs.__keywords;
|
||||
delete args.__keywords;
|
||||
if (this.args.domainId !== 'system') {
|
||||
name += '_with_domainId';
|
||||
kwargs.domainId = kwargs.domainId || this.args.domainId;
|
||||
args.domainId = args.domainId || this.args.domainId;
|
||||
}
|
||||
const { anchor, query } = kwargs;
|
||||
delete kwargs.anchor;
|
||||
delete kwargs.query;
|
||||
if (query) res = router.url(name, kwargs, { query });
|
||||
else res = router.url(name, kwargs);
|
||||
const { anchor, query } = args;
|
||||
delete args.anchor;
|
||||
delete args.query;
|
||||
if (query) res = router.url(name, args, { query });
|
||||
else res = router.url(name, args);
|
||||
if (anchor) return `${res}#${anchor}`;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
console.log(name, kwargs);
|
||||
console.log(name, args);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -417,19 +418,20 @@ class ConnectionHandler {
|
||||
for (const i in p) this.request.params[p[i][0]] = decodeURIComponent(p[i][1]);
|
||||
}
|
||||
|
||||
url(name, kwargs = {}) { // eslint-disable-line class-methods-use-this
|
||||
url(name, kwargs = {}) {
|
||||
let res = '#';
|
||||
const args = { ...kwargs };
|
||||
try {
|
||||
delete kwargs.__keywords;
|
||||
delete args.__keywords;
|
||||
if (this.args.domainId !== 'system') {
|
||||
name += '_with_domainId';
|
||||
kwargs.domainId = kwargs.domainId || this.args.domainId;
|
||||
args.domainId = args.domainId || this.args.domainId;
|
||||
}
|
||||
const { anchor, query } = kwargs;
|
||||
delete kwargs.anchor;
|
||||
delete kwargs.query;
|
||||
if (query) res = router.url(name, kwargs, { query });
|
||||
else res = router.url(name, kwargs);
|
||||
const { anchor, query } = args;
|
||||
delete args.anchor;
|
||||
delete args.query;
|
||||
if (query) res = router.url(name, args, { query });
|
||||
else res = router.url(name, args);
|
||||
if (anchor) return `${res}#${anchor}`;
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
|
||||
Reference in new issue
Block a user