@codemaskjs/nestjs-passport
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,1 +0,1 @@ | ||
export declare const Payload: (fieldName?: string) => ParameterDecorator; | ||
export declare const Payload: (propertyName?: string) => ParameterDecorator; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Payload = void 0; | ||
const ramda_1 = require("ramda"); | ||
const common_1 = require("@nestjs/common"); | ||
const constants_1 = require("../constants"); | ||
const Payload = (fieldName = constants_1.PASSPORT_DEFAULT_PROPERTY) => (0, common_1.createParamDecorator)((_, ctx) => ctx.switchToHttp().getRequest()[fieldName]); | ||
const Payload = (propertyName = constants_1.PASSPORT_DEFAULT_PROPERTY) => { | ||
const decorator = (0, common_1.createParamDecorator)((_, context) => { | ||
const request = context.switchToHttp().getRequest(); | ||
const payload = request[propertyName]; | ||
if ((0, ramda_1.isNil)(payload)) { | ||
throw new Error(`Payload not found under property name: ${propertyName}`); | ||
} | ||
return payload; | ||
}); | ||
return decorator(); | ||
}; | ||
exports.Payload = Payload; | ||
//# sourceMappingURL=payload.decorator.js.map |
export * from './types'; | ||
export * from './constants'; | ||
export * from './decorators'; | ||
@@ -3,0 +4,0 @@ export * from './utils'; |
@@ -18,2 +18,3 @@ "use strict"; | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./constants"), exports); | ||
__exportStar(require("./decorators"), exports); | ||
@@ -20,0 +21,0 @@ __exportStar(require("./utils"), exports); |
@@ -62,10 +62,3 @@ "use strict"; | ||
return new Promise(resolve => { | ||
const callback = (error, payload, data, status) => { | ||
if (error || status) { | ||
this.logger.debug({ strategyName, error, status, payload, data }); | ||
return resolve(false); | ||
} | ||
resolve(true); | ||
}; | ||
passport_1.default.authenticate(strategyName, this.authenticateOptions, callback)(request, response, (error) => { | ||
passport_1.default.authenticate(strategyName, this.authenticateOptions)(request, response, (error) => { | ||
if (error) { | ||
@@ -72,0 +65,0 @@ this.logger.debug({ strategyName, error }); |
@@ -0,3 +1,3 @@ | ||
import { Logger } from '@nestjs/common'; | ||
import { Class, StrategyOptions } from '..'; | ||
import { Logger } from '@nestjs/common'; | ||
export declare const PassportStrategy: <TStrategy extends Class>(strategy: TStrategy, name?: string | symbol) => abstract new () => { | ||
@@ -4,0 +4,0 @@ readonly logger: Logger; |
@@ -9,5 +9,5 @@ "use strict"; | ||
const passport_1 = __importDefault(require("passport")); | ||
const constants_1 = require("../constants"); | ||
const common_1 = require("@nestjs/common"); | ||
const PassportStrategy = (strategy, name = constants_1.PASSPORT_DEFAULT_STRATEGY_NAME) => { | ||
const module_1 = require(".."); | ||
const PassportStrategy = (strategy, name = module_1.PASSPORT_DEFAULT_STRATEGY_NAME) => { | ||
class Strategy { | ||
@@ -41,3 +41,3 @@ logger = new common_1.Logger(Strategy.name); | ||
]; | ||
passport_1.default.use(name, new strategy(...params.filter(param => (0, ramda_1.isNotNil)(param)))); | ||
passport_1.default.use(this.name, new strategy(...params.filter(param => (0, ramda_1.isNotNil)(param)))); | ||
} | ||
@@ -44,0 +44,0 @@ } |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Nestjs Passport Module", | ||
@@ -67,2 +67,3 @@ "main": "dist/index.js", | ||
"@types/passport": "1.0.16", | ||
"@types/passport-jwt": "3.0.13", | ||
"@types/passport-local": "1.0.38", | ||
@@ -69,0 +70,0 @@ "@types/ramda": "0.29.9", |
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
32042
419
49