mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
template into ui
This commit is contained in:
1 parent
43ee86d34b
commit
8bb389eedd
13 files changed
+70
-206
No files matched your search
@@ -5,7 +5,6 @@ import { PRIV } from '../model/builtin';
|
||||
import * as system from '../model/system';
|
||||
import * as file from '../model/file';
|
||||
import * as user from '../model/user';
|
||||
import * as markdown from '../lib/markdown';
|
||||
import * as db from '../service/db';
|
||||
import {
|
||||
Route, Handler, Types, param, multipart,
|
||||
@@ -103,15 +102,6 @@ class SwitchLanguageHandler extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
class MarkdownHandler extends Handler {
|
||||
async post({ text, html = false, inline = false }) {
|
||||
this.response.body = inline
|
||||
? markdown.renderInline(text, html)
|
||||
: markdown.render(text, html);
|
||||
this.response.type = 'text/html';
|
||||
}
|
||||
}
|
||||
|
||||
class SockToken extends Handler {
|
||||
async get() {
|
||||
this.response.body = { token: this.UIContext.token };
|
||||
@@ -153,7 +143,6 @@ export async function apply() {
|
||||
Route('status', '/status', StatusHandler);
|
||||
Route('status_update', '/status/update', StatusUpdateHandler);
|
||||
Route('switch_language', '/language/:lang', SwitchLanguageHandler);
|
||||
Route('markdown', '/markdown', MarkdownHandler);
|
||||
Route('token', '/token', SockToken);
|
||||
Route('ui', '/extra.css', UiSettingsHandler);
|
||||
}
|
||||
|
||||
+11
-6
@@ -238,7 +238,9 @@ class OauthHandler extends Handler {
|
||||
}
|
||||
|
||||
class OauthCallbackHandler extends Handler {
|
||||
async github({ state, code }) {
|
||||
@param('state', Types.String)
|
||||
@param('code', Types.String)
|
||||
async github(domainId: string, state: string, code: string) {
|
||||
const [appid, secret, url, proxy, s] = await Promise.all([
|
||||
system.get('oauth.githubappid'),
|
||||
system.get('oauth.githubsecret'),
|
||||
@@ -272,13 +274,14 @@ class OauthCallbackHandler extends Handler {
|
||||
uname: [userInfo.body.name, userInfo.body.login],
|
||||
};
|
||||
this.response.redirect = s.redirect;
|
||||
await token.del(s, token.TYPE_OAUTH);
|
||||
await token.del(s._id, token.TYPE_OAUTH);
|
||||
return ret;
|
||||
}
|
||||
|
||||
async google({
|
||||
code, error, state,
|
||||
}) {
|
||||
@param('state', Types.String)
|
||||
@param('code', Types.String)
|
||||
@param('error', Types.String)
|
||||
async google(domainId: string, state: string, code: string, error: string) {
|
||||
if (error) throw new UserFacingError(error);
|
||||
const [
|
||||
[appid, secret, url, proxy],
|
||||
@@ -308,9 +311,11 @@ class OauthCallbackHandler extends Handler {
|
||||
};
|
||||
}
|
||||
|
||||
async get(args) {
|
||||
async get(args: any) {
|
||||
let r;
|
||||
// @ts-ignore
|
||||
if (args.type === 'github') r = await this.github(args);
|
||||
// @ts-ignore
|
||||
else if (args.type === 'google') r = await this.google(args);
|
||||
else throw new UserFacingError('Oauth type');
|
||||
const udoc = await user.getByEmail('system', r.email);
|
||||
|
||||
Reference in new issue
Block a user