Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
return user;
},
});
const accountsServer = new AccountsServer(
{
db: new MongoDBInterface(db),
tokenSecret: 'secret',
},
{
password: accountsPassword,
}
);
accountsServer.on(ServerHooks.ValidateLogin, ({ user }) => {
// This hook is called every time a user try to login.
// You can use it to only allow users with verified email to login.
// If you throw an error here it will be returned to the client.
});
app.use(accountsExpress(accountsServer));
app.get('/user', userLoader(accountsServer), (req, res) => {
res.json({ user: (req as any).user });
});
app.listen(4000, () => {
console.log('Server listening on port 4000');
});