TypeScript-Node-Starter icon indicating copy to clipboard operation
TypeScript-Node-Starter copied to clipboard

Error: Unknown authentication strategy "local"

Open santekotturi opened this issue 7 years ago • 5 comments
trafficstars

When running the app as cloned, I got Error: Unknown authentication strategy "local" from

controllers/user.ts line 41: passport.authenticate("local", ...

I remedied it by importing the configured passport instance from config/passport.ts.

Added export default passport; to the end of config/passport.ts so that I could import it in controllers/user.ts

import { default as passport } from '../config/passport'

I'm curious, I presume the error is because I'm doing something wrong, just not sure what ¯_(ツ)_/¯

[EDIT] also had to add app.use(passport.initialize()); to app.ts 🤔

santekotturi avatar Mar 22 '18 21:03 santekotturi

I am having exactly the same issue here ...

ghost avatar Apr 25 '18 14:04 ghost

@skotturi Could you try to import configuration file? resolve by add one line below

# controller/user.ts
......
import "../config/passport";

ToryTran avatar May 30 '18 07:05 ToryTran

Had the same problem. Turns out that importing passport config without actually using it in app.ts means the same as not importing it. replacing import * as passportConfig from "./config/passport"; with import "./config/passport"; solves the issue.

rafal-r avatar Oct 23 '19 20:10 rafal-r

yo tengo este problema y no se como solucionarlo , alguien me puede ayudar?

PabloCh95 avatar Apr 15 '20 20:04 PabloCh95

I was having the same problem, i don't know if it's something related to you guys, but i was importing passport from the actual passport module, instead of the passport.js i had created, so: instead of this: import passport from 'passport.js' i used this: import passport from './passport.js'

Versiani-R avatar Jul 19 '20 20:07 Versiani-R