А в чём проблема-то?не знаю) опыта маловато а сомнений многовато((((
order: [
[ 'id', 'DESC' ]
]
router.get('/index', (req, res) => {
let result = User.findAll({
offset: 0, limit: 10
}, {order: db.fn('max', db.col('id'))}).then(result => {
res.render('index', {result: result});
console.log(result);
})
router.get('/index', (req, res) => {
let getProfile = User.findAll({
offset: 0, limit: 1
}).then(result => {
res.render('index', {data: result});
})
console.log(getProfile);
router.post('/signup', passport.authenticate('signup', {
//successRedirect: '/index', //из passport.use берется signup
failureRedirect: '/signup',
failureFlash: false
}), function(req, res, next){
res.redirect('/index');
});
const user = await User.create({
email,
password,
username <-----------------------------------------
});
passport.use('signup', new LocalStrategy(
{
usernameField: 'email',
passwordField: 'password',
passReqToCallback: true
},
async (req, email, password, done) => {
try {
const findUser = await User.findOne({
where: { email }
}); //console.log(req.body.username);
let username = req.body.username <------------------------------
//console.log(username);
if (findUser) {
done(null, false, {
message: 'Email already taken'
});
return;
}
const user = await User.create({
email,
password,
username <-----------------------------------------
});
done(null, user);
} catch (error) {
done(error);
}
}
));
.......
secret: undefined,
cookies:
{ 'connect.sid': .....' },
signedCookies: {},
body:
{ username: 'qeqeq',
email: 'tetretr',
password: 'tretrrt' },
passport.use('signup', new LocalStrategy(
{
usernameField: 'email',
passwordField: 'password',
passReqToCallback: true
},
async (req, email, password, done) => {
try {
const findUser = await User.findOne({
where: { email }
}); //console.log(req);
if (findUser) {
done(null, false, {
message: 'Email already taken'
});
return;
}
const user = await User.create({
email,
password,
req.body.username
});
done(null, user);
} catch (error) {
done(error);
}
}
));