microsoft / TypeScript-Node-Starter

A reference example for TypeScript and Node with a detailed README describing how to use the two together.
MIT License
11.31k stars 2.77k forks source link

Error: Unknown authentication strategy "local" #102

Open santekotturi opened 6 years ago

santekotturi commented 6 years ago

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 🤔

ghost commented 6 years ago

I am having exactly the same issue here ...

ToryTran commented 6 years ago

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

# controller/user.ts
......
import "../config/passport";
rafal-r commented 4 years ago

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.

PabloCh95 commented 4 years ago

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

Versiani-R commented 4 years ago

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'