@@ -6,26 +6,6 @@ var path = require('path');
66var app = module . exports = loopback ( ) ;
77var env = require ( 'get-env' ) ( ) ;
88
9- /*
10- * body-parser is a piece of express middleware that
11- * reads a form's input and stores it as a javascript
12- * object accessible through `req.body`
13- *
14- */
15- var bodyParser = require ( 'body-parser' ) ;
16-
17- // Passport configurators..
18- var loopbackPassport = require ( 'loopback-component-passport' ) ;
19-
20- var PassportConfigurator = loopbackPassport . PassportConfigurator ;
21- var passportConfigurator = new PassportConfigurator ( app ) ;
22-
23- //app.use(function(req, res, next) {
24- // res.setHeader('X-Powered-By', 'Loopback Admin');
25- // res.removeHeader('Vary');
26- // next();
27- //});
28-
299// Set up the /favicon.ico
3010app . use ( loopback . favicon ( ) ) ;
3111
@@ -34,84 +14,10 @@ app.use(loopback.compress());
3414
3515// -- Add your pre-processing middleware here --
3616
37- var ds = loopback . createDataSource ( {
38- connector : require ( 'loopback-component-storage' ) ,
39- provider : 'filesystem' ,
40- root : path . join ( __dirname , '../' , 'storage' )
41- } ) ;
42- var container = ds . createModel ( 'container' ) ;
43-
44- app . model ( container ) ;
4517
4618// boot scripts mount components like REST API
4719boot ( app , __dirname ) ;
4820
49- // to support JSON-encoded bodies
50- app . use ( bodyParser . json ( ) ) ;
51- // to support URL-encoded bodies
52- app . use ( bodyParser . urlencoded ( {
53- extended : true
54- } ) ) ;
55-
56- // The access token is only available after boot
57- app . use ( loopback . token ( {
58- model : app . models . accessToken
59- } ) ) ;
60-
61- // Enable http session
62- //app.use(loopback.cookieParser(app.get('cookieSecret')));
63- app . use ( loopback . session ( {
64- secret : 'kitty' ,
65- saveUninitialized : true ,
66- resave : true
67- } ) ) ;
68-
69- // Load the provider configurations
70- var config = { } ;
71- try {
72- config = require ( '../providers.json' ) ;
73- } catch ( err ) {
74- console . error ( 'Please configure your passport strategy in `providers.json`.' ) ;
75- console . error ( 'Copy `providers.json.template` to `providers.json` and replace the clientID/clientSecret values with your own.' ) ;
76- process . exit ( 1 ) ;
77- }
78- // Initialize passport
79- passportConfigurator . init ( ) ;
80-
81- // Set up related models
82- passportConfigurator . setupModels ( {
83- userModel : app . models . user ,
84- userIdentityModel : app . models . userIdentity ,
85- userCredentialModel : app . models . userCredential
86- } ) ;
87- // Configure passport strategies for third party auth providers
88- for ( var s in config ) {
89- var c = config [ s ] ;
90- c . session = c . session !== false ;
91- passportConfigurator . configureProvider ( s , c ) ;
92- }
93-
94-
95- var ensureLoggedIn = require ( 'connect-ensure-login' ) . ensureLoggedIn ;
96-
97- app . get ( '/auth/account' , ensureLoggedIn ( '/login.html' ) , function ( req , res , next ) {
98- res . render ( 'pages/loginProfiles' , {
99- user : req . user ,
100- url : req . url
101- } ) ;
102- } ) ;
103-
104- app . get ( '/link/account' , ensureLoggedIn ( '/login.html' ) , function ( req , res , next ) {
105- res . render ( 'pages/linkedAccounts' , {
106- user : req . user ,
107- url : req . url
108- } ) ;
109- } ) ;
110-
111- app . get ( '/auth/logout' , function ( req , res , next ) {
112- req . logout ( ) ;
113- res . redirect ( '/' ) ;
114- } ) ;
11521
11622// -- Mount static files here--
11723// All static middleware should be registered at the end, as all requests
0 commit comments