Skip to content

Commit

Permalink
Merge pull request #34 from FACN1/logOut
Browse files Browse the repository at this point in the history
add a logout button to all pages after logged in #21
  • Loading branch information
macintoshhelper authored Apr 13, 2017
2 parents 1ae6bbb + 26beaa2 commit ab3dbf4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const loginHandler = require('./login.js');
const welcomeHandler = require('./welcome.js');
const postsHandler = require('./posts.js');
const addPostHandler = require('./addPost.js');
const logoutHandler = require('./logout.js');

module.exports = [
homeHandler,
Expand All @@ -15,5 +16,6 @@ module.exports = [
loginHandler,
welcomeHandler,
postsHandler,
addPostHandler
addPostHandler,
logoutHandler
];
12 changes: 12 additions & 0 deletions src/routes/logout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require('env2')('./config.env');

module.exports = {
method: 'GET',
path: '/logout',
handler: (request, reply) => reply.redirect('/')
.state('token', null, {
path: '/',
isHttpOnly: false,
isSecure: process.env.NODE_ENV === 'PRODUCTION'
})
};
1 change: 1 addition & 0 deletions src/views/partials/header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div class="user-info">
<img src="{{avatar_url}}" alt="{{username}}'s profile picture">
<strong>{{username}}</strong>
<a class="logout-button btn" href="/logout" >logOut</a>
</div>
{{/if}}
<h1>{{title}}</h1>
Expand Down

0 comments on commit ab3dbf4

Please sign in to comment.