我收到 SyntaxError: Unexpected token else in nodejs app in line 92 col7
在 app.js 中
var express = require('express'), everyauth = require('everyauth');
everyauth.debug = true;
var usersByLogin = {
'krishna': {
login: 'krishna',
email: 'krishna@blogab.com',
password: 'krishna'
}
};
everyauth
.password
//.loginWith('email')
.loginWith('login')
.getLoginPath('/login')
.postLoginPath('/login')
.loginView('bcore/login.jade')
.loginLocals( function (req, res, done) {
setTimeout( function () {
done(null, {
title: 'blogab - login'
});
}, 200);
})
.authenticate( function (login, password) {
var errors = [];
if (!login) errors.push('Missing login');
if (!password) errors.push('Missing password');
if (errors.length) return errors;
var user = usersByLogin[login];
if (!user) return ['Login failed'];
if (user.password !== password) return ['Login failed'];
return user;
})
.getRegisterPath('/register')
.postRegisterPath('/register')
.registerView('bcore/register.jade')
.registerLocals( function (req, res, done) {
setTimeout( function () {
done(null, {
title: ' Register'
});
}, 200);
})
.extractExtraRegistrationParams( function (req) {
return {
email: req.body.email
};
})
.validateRegistration( function (newUserAttrs, errors) {
var login = newUserAttrs.login;
if (usersByLogin[login]) errors.push('Login already taken');
return errors;
})
.registerUser( function (newUserAttrs) {
var login = newUserAttrs[this.loginKey()];
return usersByLogin[login] = newUserAttrs;
})
.loginSuccessRedirect('/admin/')
.registerSuccessRedirect('/admin/');
var app = express.createServer(
express.bodyParser(),
express.static(__dirname + "/public"),
express.cookieParser(),
express.session({ secret: 'htuayreve'}),
everyauth.middleware()
);
app.configure( function () {
app.set('view engine', 'jade');
});
app.get('/', function (req, res) {
res.render('templates/default/index', {
title: 'blogab',
users: JSON.stringify(usersByLogin, null, 2)
});
});
app.get('/login', function (req, res) {
res.render('bcore/login', {
title: 'login',
users: JSON.stringify(usersByLogin, null, 2)
});
});
app.get('/admin/newpost', function (req, res) {
res.render('bcore/newpost', {
title: 'Blogab-newpost',
users: ';
JSON.stringify(usersByLogin, null, 2)
});
});
app.get('/admin/', function (req, res) {
res.render('bcore/admin', {
title: 'core',
users: JSON.stringify(usersByLogin, null, 2)
});
});
everyauth.helpExpress(app);
app.listen(1224, function(){
console.log("blogab is running on port %d in %s mode", app.address().port, app.settings.env);
});
我不知道我做错了什么我在重定向 url 为 \ 之前使用everyauth 它工作正常但是当我改变它时它不能正常工作