Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
eat: Create the auth_username_pasword module
Browse files Browse the repository at this point in the history
  • Loading branch information
Blckbrry-Pi committed Aug 24, 2024
1 parent 4381160 commit d8ad2c8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/auth_username_password/tests/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ test("test_sign_in", async (ctx: TestContext) => {
userToken: token.token,
});

<<<<<<< HEAD
const { users: [user] } = await ctx.modules.users.fetchByUsername({
=======
const { users: [user] } = await ctx.modules.users.fetchByUname({
>>>>>>> 7d761a9 (eat: Create the `auth_username_pasword` module)
usernames: [username],
});

Expand Down
24 changes: 24 additions & 0 deletions modules/users/scripts/fetch_by_uname.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ScriptContext } from "../module.gen.ts";
import { User } from "../utils/types.ts";

export interface Request {
usernames: string[];
}

export interface Response {
users: User[];
}

export async function run(
ctx: ScriptContext,
req: Request,
): Promise<Response> {
await ctx.modules.rateLimit.throttlePublic({});

const users = await ctx.db.user.findMany({
where: { username: { in: req.usernames } },
orderBy: { username: "desc" },
});

return { users };
}

0 comments on commit d8ad2c8

Please sign in to comment.