我正在使用next.js,next-connect和passport.js身份验证,如果用户登录,我想在_app.js中获得一个标志。但是我的实现给出了错误。
// error
./node_modules/@firebase/database/dist/index.cjs.js
Module not found: Can't resolve '@firebase/app
// code passport.js
import passport from 'passport';
import { Strategy as LocalStrategy } from 'passport-local';
import {authenticate} from '../services/user/user';
passport.serializeUser((user, done) => {
done(null, user._id.toString());
});
passport.deserializeUser((req, id, done) => {
done(null, {_id: id});
});
passport.use(
new LocalStrategy(
{
usernameField: 'email',
passReqToCallback: true
},
async (req, email, password, done) => {
authenticate(email, password)
.then(res => {
res.success ? done(null, res.user) : done(null, false, res.error);
})
.catch(err => {
done(null, false, 'Invalid login details');
});
},
),
);
export default passport;