Skip to content

Commit

Permalink
Merge pull request #305 from amplication/fix/auth-jwt
Browse files Browse the repository at this point in the history
add auth entity service findOne function dynamic name
  • Loading branch information
mulygottlieb authored Dec 5, 2023
2 parents 3524d69 + c850428 commit 6442473
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
16 changes: 16 additions & 0 deletions plugins/auth-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.5]

This version:

- adds support for new DSG v3.0.0.

### Changes

<li> <a href="http://github.com/amplication/plugins/commit/47277ef2e9daf2c17ccb2c9ebc7f9acbc256bc1d">42a3f2b &bull;</a> feat(auth-core):update auth-service template with a dynamic authEntity findOne function name</li>
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 6442473

Please sign in to comment.