feat: add async suffix eslint rule (#485)

This commit is contained in:
Manuel
2024-05-18 12:25:33 +02:00
committed by GitHub
parent 5723295856
commit dcaff1d91c
60 changed files with 296 additions and 225 deletions

View File

@@ -22,6 +22,7 @@ export const createCredentialsConfiguration = (db: Database) =>
type: "password",
},
},
// eslint-disable-next-line no-restricted-syntax
async authorize(credentials) {
const data = await validation.user.signIn.parseAsync(credentials);

View File

@@ -4,18 +4,18 @@ import { createId } from "@homarr/db";
import { users } from "@homarr/db/schema/sqlite";
import { createDb } from "@homarr/db/test";
import { createSalt, hashPassword } from "../../security";
import { createSaltAsync, hashPasswordAsync } from "../../security";
import { createCredentialsConfiguration } from "../credentials";
describe("Credentials authorization", () => {
it("should authorize user with correct credentials", async () => {
const db = createDb();
const userId = createId();
const salt = await createSalt();
const salt = await createSaltAsync();
await db.insert(users).values({
id: userId,
name: "test",
password: await hashPassword("test", salt),
password: await hashPasswordAsync("test", salt),
salt,
});
const result = await createCredentialsConfiguration(db).authorize({
@@ -38,11 +38,11 @@ describe("Credentials authorization", () => {
it(`should not authorize user with incorrect credentials (${password})`, async () => {
const db = createDb();
const userId = createId();
const salt = await createSalt();
const salt = await createSaltAsync();
await db.insert(users).values({
id: userId,
name: "test",
password: await hashPassword("test", salt),
password: await hashPasswordAsync("test", salt),
salt,
});
const result = await createCredentialsConfiguration(db).authorize({