Skip to content
Snippets Groups Projects
Commit d435778a authored by Elferink, A.S. (Amber)'s avatar Elferink, A.S. (Amber)
Browse files

logout success

parent 8dcf2a37
No related branches found
No related tags found
No related merge requests found
......@@ -47,7 +47,7 @@ function validate() {
function postLogin(callback, un, pw) {
$.ajax({
type: 'POST',
url: '/api/checkLogin',
url: '/api/checkLogin/login',
dataType: 'json',
data: {
"username": un,
......
$('#logout').click(function () {
$.ajax({
type: 'GET',
url: '/api/checkLogin/logout',
dataType: 'text',
})//als deze asynchronous ajax call klaar is, is het of gefaald, of goed gegaan.
//als het goed is gegaan, callt hij de .done hieronder.
.done(function (data) {
//deze done functie logt het naar de javascript console en print het op de pagina als txt
//console.log('GET response:', JSON.stringify(data, "", 2));
console.log(data);
})
//als het niet goed is gegaan, doet hij de fail hieronder
.fail(function (jqXHR, textStatus, err) {
console.log('AJAX error response:', textStatus);
});
});
\ No newline at end of file
......@@ -17,7 +17,7 @@ app.use(session({
}));
/* GET home page. */
router.post('/', function (req, res) {
router.post('/login', function (req, res) {
//dit function deel is hetgene waarmee de callback(undefined, rows) wordt aangeroepen
//alles binnen deze functie doet hij pas nadat de callback is uitgevoerd. Als je res.send(data);
......@@ -30,6 +30,12 @@ router.post('/', function (req, res) {
},req.body);
});
router.get('/logout', function (req, res) {
console.log("I am logging out");
req.session.destroy();
res.send("logout success!");
});
module.exports = router;
......
......@@ -23,13 +23,14 @@
<li><a href="#">Order History</a></li>
<li><a href="#"></a>Blabla</li>
<li role="separator" class="divider"></li>
<li><a href="#">Log out</a></li>
<li><a id="logout">Log out</a></li>
</ul>
</li>
</ul>
</div>
</nav>
<script type=text/javascript src="javascripts/navbar.js"></script>
<!--
<nav class="navbar navbar-default">
<div class="container-fluid">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment