'use strict';

var Handler = require('./handlers');

const routes = [
  {
    path: '/auth/twitter',
    method: 'GET',
    config: {
      auth: 'twitter',
      handler: Handler.sessionManagement
    }
  },
  {
    path: '/auth/facebook',
    method: 'GET',
    config: {
      auth: 'facebook',
      handler: Handler.sessionManagement
    }

  },
  {
    path: '/auth/google',
    method: 'GET',
    config: {
      auth: 'google',
      handler: Handler.sessionManagement
    }
  },
  {
    path: '/logout',
    method: 'GET',
    config: {
      handler: function (request, reply) {

        let auth = request.auth;

        if (auth.isAuthenticated) {
          request.cookieAuth.clear();
        }
        return reply.redirect('/');
      },
      auth: {
        strategy: 'session',
        mode: 'try'
      },
      plugins: {'hapi-auth-cookie': {redirectTo: false}}
    }
  }
];

module.exports = routes;

@@ -12,19 +12,22 @@
 ';%0A%0A
-var H
+const h
 andler
+s
  = r
@@ -160,39 +160,40 @@
 %0A      handler: 
-H
+h
 andler
+s
 .sessionManageme
@@ -302,39 +302,40 @@
 %0A      handler: 
-H
+h
 andler
+s
 .sessionManageme
@@ -453,15 +453,16 @@
 er: 
-H
+h
 andler
+s
 .ses
@@ -743,16 +743,16 @@
 t('/');%0A
-
       %7D,
@@ -887,16 +887,636 @@
 %7D%0A    %7D%0A
+  %7D,%0A  %7B%0A    method: 'GET',%0A    path: '/auth',%0A    config: %7B%0A      handler(request, reply)%7B%0A%0A        let auth = request.auth;%0A%0A        if (auth.isAuthenticated) %7B%0A%0A          auth.credentials.token = undefined;%0A%0A          reply(%0A            %7B%0A              auth: auth.credentials,%0A              isLoggedIn: true%0A            %7D);%0A%0A        %7D else %7B%0A          reply(%0A            %7B%0A              isLoggedIn: false%0A            %7D);%0A        %7D%0A%0A      %7D,%0A      tags: %5B'web'%5D,%0A      validate: %7B%7D,%0A      auth: %7B%0A        strategy: 'session',%0A        mode: 'try'%0A      %7D,%0A      plugins: %7B'hapi-auth-cookie': %7BredirectTo: false%7D%7D%0A    %7D%0A
   %7D%0A%5D;%0A%0A

add check login