Completed
Push — master ( 416db6...de75b8 )
by Neil
01:28
created

module.exports   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
dl 0
loc 4
rs 10
nop 2
1
var passport = require('passport')
2
const passportConfig = require('../config/passport')
3
4
module.exports = function (app) {
5
  // GET /auth/google
6
  //   Use passport.authenticate() as route middleware to authenticate the
7
  //   request.  The first step in Google authentication will involve
8
  //   redirecting the user to google.com.  After authorization, Google
9
  //   will redirect the user back to this application at /auth/google/callback
10
  app.get('/auth/google', passport.authenticate('google', {
11
    scope: [
12
      'https://www.googleapis.com/auth/plus.login',
13
      'https://www.googleapis.com/auth/plus.profile.emails.read']
14
  }))
15
16
  // GET /auth/google/callback
17
  //   Use passport.authenticate() as route middleware to authenticate the
18
  //   request.  If authentication fails, the user will be redirected back to the
19
  //   login page.  Otherwise, the primary route function function will be called,
20
  //   which, in this example, will redirect the user to the home page.
21
  app.get('/auth/google/callback',
22
    passport.authenticate('google', {
23
      successRedirect: '/',
24
      failureRedirect: '/auth/login'
25
    }))
26
27
  app.get('/account', passportConfig.ensureAuthenticated, function (req, res) {
28
    console.log(req)
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
29
    res.render('account', { user: req.user })
30
  })
31
32
  app.get('/auth/login', function (req, res) {
33
    res.render('login', { user: req.user })
34
  })
35
36
  app.get('/auth/logout', function (req, res) {
37
    req.logout()
38
    res.redirect('/')
39
  })
40
}
41