@applers/auth-magic-link-nest
Advanced tools
Comparing version 4.0.0 to 5.0.0
@@ -82,3 +82,3 @@ "use strict"; | ||
(0, common_1.Post)(paths.magicLink.request)(login_controller_1.LoginController, login_controller_1.LoginController.prototype.requestMagicLink.name, Object.getOwnPropertyDescriptor(login_controller_1.LoginController.prototype, login_controller_1.LoginController.prototype.requestMagicLink.name)); | ||
(0, common_1.Get)(paths.magicLink.validate.success)(login_controller_1.LoginController, login_controller_1.LoginController.prototype.validate.name, Object.getOwnPropertyDescriptor(login_controller_1.LoginController.prototype, login_controller_1.LoginController.prototype.validate.name)); | ||
(0, common_1.Get)(paths.magicLink.validate)(login_controller_1.LoginController, login_controller_1.LoginController.prototype.validate.name, Object.getOwnPropertyDescriptor(login_controller_1.LoginController.prototype, login_controller_1.LoginController.prototype.validate.name)); | ||
(0, common_1.Post)(paths.magicLink.logout)(login_controller_1.LoginController, login_controller_1.LoginController.prototype.logout.name, Object.getOwnPropertyDescriptor(login_controller_1.LoginController.prototype, login_controller_1.LoginController.prototype.logout.name)); | ||
@@ -91,3 +91,3 @@ // should be ok to apply it on all routes | ||
.apply(authentication_middleware_1.AuthenticationMiddleware) | ||
.exclude(paths.magicLink.request, paths.magicLink.validate.success, ...(paths.auth?.exclude ?? [])) | ||
.exclude(paths.magicLink.request, paths.magicLink.validate, ...(paths.auth?.exclude ?? [])) | ||
.forRoutes('*'); | ||
@@ -94,0 +94,0 @@ } |
@@ -33,6 +33,6 @@ "use strict"; | ||
const status = exception.getStatus(); | ||
const redirectPath = this.config.paths.magicLink.validate.failure; | ||
if (redirectPath) { | ||
this.cookieTokenService.removeCookies(response); | ||
response.status(status).redirect(redirectPath); | ||
this.cookieTokenService.removeCookies(response); | ||
const failureRedirectPath = this.config.frontendUrls.auth.redirect.failure; | ||
if (failureRedirectPath) { | ||
response.status(status).redirect(failureRedirectPath); | ||
} | ||
@@ -39,0 +39,0 @@ else { |
@@ -15,6 +15,3 @@ import { RouteInfo } from '@nestjs/common/interfaces'; | ||
request: string; | ||
validate: { | ||
success: string; | ||
failure?: string; | ||
}; | ||
validate: string; | ||
logout: string; | ||
@@ -26,6 +23,14 @@ }; | ||
} | ||
export interface AuthMagicLinkFrontendUrlsConfig { | ||
auth: { | ||
redirect: { | ||
success: string; | ||
failure?: string; | ||
}; | ||
}; | ||
} | ||
export declare const ExcludedRouteMethod: typeof RequestMethod; | ||
export interface AuthMagicLinkConfig { | ||
frontendUrls: AuthMagicLinkFrontendUrlsConfig; | ||
paths: AuthMagicLinkPathsConfig; | ||
redirectUrl: string; | ||
httpsOnly: boolean; | ||
@@ -32,0 +37,0 @@ magicLinkToken: TokenConfig; |
@@ -35,6 +35,6 @@ "use strict"; | ||
async validate(response, email) { | ||
const { redirectUrl } = this.config; | ||
const { frontendUrls } = this.config; | ||
const { userId } = await this.util.findOrCreateByEmail({ email }); | ||
await this.cookieTokenService.prepareResponseWithNewTokens(response, userId); | ||
response.redirect(redirectUrl); | ||
response.redirect(frontendUrls.auth.redirect.success); | ||
return; | ||
@@ -41,0 +41,0 @@ } |
@@ -39,3 +39,3 @@ "use strict"; | ||
this.config.paths.proxy ?? '', | ||
this.config.paths.magicLink.validate.success, | ||
this.config.paths.magicLink.validate, | ||
]) | ||
@@ -42,0 +42,0 @@ .query({ token }) |
import { DeepRequired, Merge } from 'ts-essentials'; | ||
import { AuthMagicLinkConfig, AuthMagicLinkPathsConfig } from './environment.types'; | ||
export type FullAuthMagicLinkConfig = Merge<DeepRequired<Omit<AuthMagicLinkConfig, 'paths'>>, { | ||
import { AuthMagicLinkConfig, AuthMagicLinkFrontendUrlsConfig, AuthMagicLinkPathsConfig } from './environment.types'; | ||
export type FullAuthMagicLinkConfig = Merge<DeepRequired<Omit<AuthMagicLinkConfig, 'paths' | 'frontendUrls'>>, { | ||
paths: AuthMagicLinkPathsConfig; | ||
frontendUrls: AuthMagicLinkFrontendUrlsConfig; | ||
}>; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@applers/auth-magic-link-nest", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Can Pekesen <cpekesen@applers.de>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
174978
934
2