瀏覽代碼

fixes #1417

tags/v0.5.1^2
Shaun 4 年之前
父節點
當前提交
7e47d990ea
共有 3 個檔案被更改,包括 25 行新增5 行删除
  1. +2
    -0
      src/server/components/auth.js
  2. +19
    -4
      src/server/db/ioRethink.js
  3. +4
    -1
      src/server/db/ioSqlite.js

+ 2
- 0
src/server/components/auth.js 查看文件

@@ -298,6 +298,7 @@ module.exports = {

let exists = await io.getAsync({
key: credentials.username,
ignoreCase: true,
table: 'login',
noDefault: true,
noParse: true
@@ -372,6 +373,7 @@ module.exports = {

let exists = await io.getAsync({
key: name,
ignoreCase: true,
table: 'character',
noDefault: true
});


+ 19
- 4
src/server/db/ioRethink.js 查看文件

@@ -33,15 +33,30 @@ module.exports = {
}
},

getAsyncIgnoreCase: async function (table, key) {
const res = await r.table(table)
.filter(doc => doc('id').match(`(?i)^${key}$`))
.run();

return res[0];
},

getAsync: async function ({
table,
key,
isArray,
noDefault
noDefault,
ignoreCase
}) {
let res = await r.table(table)
.get(key)
.run();
let res = null;

if (ignoreCase)
res = await this.getAsyncIgnoreCase(table, key);
else {
res = await r.table(table)
.get(key)
.run();
}

if (res)
return res.value;


+ 4
- 1
src/server/db/ioSqlite.js 查看文件

@@ -150,7 +150,10 @@ module.exports = {
},

processGet: async function (options) {
let res = await util.promisify(this.db.get.bind(this.db))(`SELECT * FROM ${options.table} WHERE key = '${options.key}' LIMIT 1`);
const collate = options.ignoreCase ? 'COLLATE NOCASE' : '';
const query = `SELECT * FROM ${options.table} WHERE key = '${options.key}' ${collate} LIMIT 1`;
let res = await util.promisify(this.db.get.bind(this.db))(query);

if (res) {
res = res.value;



Loading…
取消
儲存