Fixing wrong database queries

This commit is contained in:
Fabian Stamm 2018-11-06 21:27:07 +01:00
parent 9cfc5643a5
commit b65c93acfc
3 changed files with 4 additions and 4 deletions

View File

@ -11,7 +11,7 @@ const JWTRoute = promiseMiddleware(async (req: Request, res: Response) => {
let { refreshtoken } = req.query;
if (!refreshtoken) throw new RequestError(req.__("Refresh token not set"), HttpStatusCode.BAD_REQUEST);
let token = await RefreshToken.findOne({ where: { token: refreshtoken }, include: [User, Permission, Client] });
let token = await RefreshToken.findOne({ token: refreshtoken });
if (!token) throw new RequestError(req.__("Invalid token"), HttpStatusCode.BAD_REQUEST);
let user = await User.findById(token.user);

View File

@ -19,7 +19,7 @@ const RefreshTokenRoute = Stacker(GetClientAuthMiddleware(false, false, true), a
let redirect_uri = req.query.redirect_uri || req.body.redirect_uri;
let grant_type = req.query.grant_type || req.body.grant_type;
if (!grant_type || grant_type === "authorization_code") {
let c = await ClientCode.findOne({ where: { code: code }, include: [{ model: User, include: [Mail] }, Client, Permission] })
let c = await ClientCode.findOne({ code: code })
if (!c) {
throw new RequestError(req.__("Invalid code"), HttpStatusCode.BAD_REQUEST);
}

View File

@ -39,7 +39,7 @@ export default async function TestData() {
await Client.save(c);
}
let perm = await Permission.findOne({ where: { id: 0 } });
let perm = await Permission.findOne({ id: 0 });
if (!perm) {
Logging.log("Adding test permission")
perm = Permission.new({
@ -51,7 +51,7 @@ export default async function TestData() {
Permission.save(perm);
}
let r = await RegCode.findOne({ where: {} });
let r = await RegCode.findOne({ token: "test" });
if (!r) {
Logging.log("Adding test reg_code")
r = RegCode.new({