Last active
August 29, 2015 14:18
-
-
Save cadecairos/5bcfa6aeba06c2c69952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Hapi = require('hapi'); | |
var Hoek = require('hoek'); | |
var Path = require('path'); | |
var server = new Hapi.Server(); | |
server.connection({ | |
host: "localhost", | |
port: 7878 | |
}); | |
server.register(require('hapi-auth-cookie'), function(err) { | |
server.auth.strategy('session', 'cookie', { | |
password: "sekret", | |
cookie: 'wat', | |
ttl: 1000 * 60 * 60 * 24, | |
isSecure: false, | |
isHttpOnly: true | |
}); | |
server.auth.default({ | |
strategy: 'session', | |
mode: 'try' | |
}); | |
}); | |
server.route([ | |
{ | |
method: 'GET', | |
path: '/', | |
handler: { | |
file: { | |
path: Path.join(__dirname, './cookie.html') | |
} | |
} | |
}, | |
{ | |
method: 'POST', | |
path: '/', | |
handler: function(request, reply) { | |
request.auth.session.set({ | |
"wat": "wat" | |
}); | |
reply({ status: 'Logged In' }); | |
} | |
} | |
]); | |
server.start(function(error) { | |
Hoek.assert(!error, error); | |
console.log('Server running at: %s', server.info.uri); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment