Commit cb9a8101 authored by nanahira's avatar nanahira

use _id_ as query prefix

parent d4f60dfe
Pipeline #19494 passed with stages
in 18 seconds
......@@ -196,13 +196,10 @@ export const UpdateAccount = async (ctx: Context) => {
async function queryUser(username: string) {
if (!username) return;
const userRepository = getEntityManager().getRepository(User);
const possibleId = parseInt(username);
const query = userRepository.createQueryBuilder('user')
.where('user.username = :username', { username })
if (!isNaN(possibleId)) {
query.orWhere('user.id = :id', { id: possibleId });
}
return query.getOne();
return await userRepository
.findOne({
where: username.startsWith('_id_') ? { id: parseInt(username.slice(3)) } : { username },
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment