mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
Google OAuth
This commit is contained in:
1 parent
8476eac3b4
commit
d2173eeb38
12 files changed
+261
-117
No files matched your search
@@ -104,6 +104,9 @@ SystemSetting(
|
||||
Setting('setting_server', 'server.port', null, 8888, 'number', 'Server Port'),
|
||||
Setting('setting_oauth', 'oauth.githubappid', null, null, 'text', 'Github Oauth AppID'),
|
||||
Setting('setting_oauth', 'oauth.githubsecret', null, null, 'text', 'Github Oauth Secret'),
|
||||
Setting('setting_oauth', 'oauth.googleappid', null, null, 'text', 'Google Oauth ClientID'),
|
||||
Setting('setting_oauth', 'oauth.googlesecret', null, null, 'text', 'Google Oauth Secret'),
|
||||
Setting('setting_proxy', 'proxy', null, null, 'text', 'Proxy Server URL'),
|
||||
Setting('setting_constant', 'PROBLEM_PER_PAGE', null, 100, 'number', 'Problems per Page'),
|
||||
Setting('setting_constant', 'CONTEST_PER_PAGE', null, 20, 'number', 'Contests per Page'),
|
||||
Setting('setting_constant', 'DISCUSSION_PER_PAGE', null, 50, 'number', 'Discussion per Page'),
|
||||
|
||||
@@ -7,10 +7,25 @@ async function get(_id) {
|
||||
if (doc) return doc.value;
|
||||
return null;
|
||||
}
|
||||
|
||||
async function getMany(keys) {
|
||||
const docs = await coll.find({ _id: { $in: keys } }).toArray();
|
||||
const dict = {};
|
||||
const res = [];
|
||||
for (const doc of docs) {
|
||||
dict[doc._id] = doc.value;
|
||||
}
|
||||
for (const key of keys) {
|
||||
res.push(dict[key] || null);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
async function update(_id, operation, config) {
|
||||
await coll.findOneAndUpdate({ _id }, operation, config);
|
||||
return get(_id);
|
||||
}
|
||||
|
||||
async function set(_id, value) {
|
||||
await coll.findOneAndUpdate({ _id }, { $set: { value } }, { upsert: true });
|
||||
return get(_id);
|
||||
@@ -25,6 +40,7 @@ function inc(field) {
|
||||
|
||||
global.Hydro.model.system = module.exports = {
|
||||
get,
|
||||
getMany,
|
||||
update,
|
||||
inc,
|
||||
set,
|
||||
|
||||
Reference in new issue
Block a user