|
|
@@ -4,6 +4,7 @@ module.exports = function(crowi, app) {
|
|
|
var googleapis = require('googleapis')
|
|
|
, debug = require('debug')('crowi:routes:login')
|
|
|
, async = require('async')
|
|
|
+ , passport = require('passport')
|
|
|
, config = crowi.getConfig()
|
|
|
, mailer = crowi.getMailer()
|
|
|
, Page = crowi.model('Page')
|
|
|
@@ -100,6 +101,34 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ actions.loginWithPassport = function(req, res, next) {
|
|
|
+ var loginForm = req.body.loginForm;
|
|
|
+
|
|
|
+ if (req.method == 'POST' && req.form.isValid) {
|
|
|
+
|
|
|
+ passport.authenticate('local', function(err, user, info) {
|
|
|
+ console.log('---passport start---');
|
|
|
+ console.log(user);
|
|
|
+ console.log(info);
|
|
|
+ console.log('---passport end ---');
|
|
|
+
|
|
|
+ if (err) { return loginFailure(req, res); }
|
|
|
+ if (!user) { return loginFailure(req, res); }
|
|
|
+ req.logIn(user, function(err) {
|
|
|
+ if (err) { loginFailure(req, res); }
|
|
|
+ return loginSuccess(req, res, user);
|
|
|
+ });
|
|
|
+ })(req, res, next);
|
|
|
+
|
|
|
+ } else { // method GET
|
|
|
+ if (req.form) {
|
|
|
+ debug(req.form.errors);
|
|
|
+ }
|
|
|
+ return res.render('login', {
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
actions.loginGoogle = function(req, res) {
|
|
|
var googleAuth = require('../util/googleAuth')(config);
|
|
|
var code = req.session.googleAuthCode || null;
|