Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a logout button to all pages after logged in #21 #34

Merged
merged 2 commits into from
Apr 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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