Skip to content

Commit

Permalink
add auth entity service findOne function dynamic name
Browse files Browse the repository at this point in the history
  • Loading branch information
morhag90 committed Nov 30, 2023
1 parent a4c6d57 commit 42a3f2b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions plugins/auth-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/auth-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplication/plugin-auth-core",
"version": "2.0.4",
"version": "2.0.5",
"description": "set auth for Amplication build",
"main": "dist/index.js",
"nx": {},
Expand Down
2 changes: 2 additions & 0 deletions plugins/auth-core/src/core/create-auth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { builders, namedTypes } from "ast-types";
import { print } from "@amplication/code-gen-utils";
import { addInjectableDependency } from "../util/nestjs-code-generation";
import { camelCase } from "lodash";

const authServicePath = join(templatesPath, "auth.service.template.ts");

Expand Down Expand Up @@ -74,6 +75,7 @@ async function mapAuthServiceTemplate(
ENTITY_NAME_INFO: builders.identifier(`${authEntity.name}Info`),
ENTITY_SERVICE: builders.identifier(`${entityNameToLower}Service`),
ENTITY_SERVICE_UPPER: builders.identifier(`${authEntity?.name}Service`),
FIND_ONE_FUNCTION: builders.identifier(`${camelCase(authEntity?.name) }`)
};

const filePath = `${serverDirectories.authDirectory}/${fileName}`;
Expand Down
2 changes: 1 addition & 1 deletion plugins/auth-core/src/templates/auth.service.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AuthService {
username: string,
password: string
): Promise<ENTITY_NAME_INFO | null> {
const user = await this.ENTITY_SERVICE.findOne({
const user = await this.ENTITY_SERVICE.FIND_ONE_FUNCTION({
where: { username },
});
if (user && (await this.passwordService.compare(password, user.password))) {
Expand Down

0 comments on commit 42a3f2b

Please sign in to comment.