Skip to content

Commit

Permalink
login and logout
Browse files Browse the repository at this point in the history
  • Loading branch information
xjsender committed Mar 22, 2015
1 parent 7e7fb2f commit dbc0abf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions controller/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ exports.login = function(req, res, next) {
res.redirect(oauth2.getAuthorizationUrl({scope: 'api'}));
}

exports.logout = function(req, res, next) {
delete res.locals.session;
delete res.req.session;
res.redirect('/');
}

exports.callback = function(req, res, next) {
console.log(req.session.oauth2);
var conn = new jsforce.Connection({
Expand Down
1 change: 1 addition & 0 deletions routes/web_router.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = function(app) {

app.get('/', site.index);
app.post('/login', site.login);
app.get('/logout', site.logout);
app.get('/about', site.about);
app.get('/oauth/callback', site.callback);
app.get('/account/o', account.list);
Expand Down
12 changes: 5 additions & 7 deletions views/template/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@
</ul>

<ul class="nav navbar-nav navbar-right">
<li><a href="#" onclick="$('#oauth-dialog').modal('show');">Login</a></li>
<li class="profile dropdown" style="display:none;">
<a href="#" onclick="if(confirm('Logout ?')) location.href='/logout';">
<span class="profile-icon"></span>
<span class="profile-name"></span>
</a>
</li>
<% if (!session.oauth2) { %>
<li><a href="#" onclick="$('#oauth-dialog').modal('show');">Login</a></li>
<%} else {%>
<li><a href="#" onclick="if(confirm('Logout ?')) location.href='/logout';">Logout</a></li>
<%}%>
</ul>
</div>
<div id="oauth-dialog" class="modal fade">
Expand Down

0 comments on commit dbc0abf

Please sign in to comment.