add facebook login image, logout link, settings modal with user id

This commit is contained in:
Tyler Renelle 2012-09-15 20:27:50 -04:00
parent 47eb7dc606
commit 3f045e0604
4 changed files with 37 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -50,11 +50,6 @@ get '/:uidParam?', (page, model, {uidParam}, next) ->
ready (model) ->
# protocol+host+port = window.location.origin, only webkit. stupid.
# also, {_purl} in template won't register, have to use $().val something is messed up
pathParts = window.location.toString().split('/')
$('#purl').val "#{pathParts[0]}//#{pathParts[2]}/#{model.get('_userId')}"
$('[rel=tooltip]').tooltip()
$('[rel=popover]').popover()
# FIXME: this isn't very efficient, do model.on set for specific attrs for popover

View file

@ -32,8 +32,8 @@ module.exports.newUserAndPurl = () ->
## -------- (2) PURL --------
# eg, http://localhost/{guid}), legacy - will be removed eventually
# tests if UUID was used (bookmarked private url), and restores that session
acceptableUid = require('guid').isGuid(uidParam) or (uidParam in ['3','9'])
if acceptableUid && sess.userId!=uidParam
acceptableUid = require('guid').isGuid(uidParam) or (uidParam == '3')
if acceptableUid && sess.userId!=uidParam && !(sess.habitRpgAuth && sess.habitRpgAuth.facebook)
# TODO check if in database - issue with accessControl which is on current uid?
sess.userId = uidParam
@ -73,7 +73,14 @@ module.exports.setupEveryauth = (everyauth) ->
fbUserMetadata
).redirectPath "/"
everyauth.everymodule.handleLogout (req, res) ->
if req.session.habitRpgAuth && req.session.habitRpgAuth.facebook
req.session.habitRpgAuth.facebook = undefined
req.session.userId = undefined
req.logout() # The logout method is added for you by everyauth, too
@redirect res, @logoutRedirectPath()
module.exports.setupQueries = (store) ->
## Setup Queries
store.query.expose 'users', 'withId', (id) ->

View file

@ -12,10 +12,34 @@
<div id="head">
<div class='pull-right'>
{#unless _facebookAuthenticated}
<a href="/auth/facebook" class='btn btn-small pull-right'><i class=icon-user></i>Login / Signup With Facebook</a>
<a href="/auth/facebook"><img src='/img/facebook-login-register.jpeg' alt="Login / Register With Facebook"/></a>
{else}
<span class=label>{_user.auth.facebook.name}</span>
{/}
<div class="btn-group">
<button class="btn btn-small">{_user.auth.facebook.name}</button>
<button class="btn btn-small dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#settings-modal" data-toggle="modal">Settings</a></li>
<!-- FIXME href='/logout' isn't redirecting the page.. window.history? -->
<li><a onclick="window.location='/logout'">Logout</a></li>
</ul>
</div>
<!-- User Settings Modal -->
<div class="modal hide" id="settings-modal" role="dialog">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Settings</h3>
</div>
<div class="modal-body">
<strong>User ID</strong><br/>
<small>Copy this ID for use in third party applications.</small>
<pre class=prettyprint>{_user.id}</pre><br/>
</div>
</div>
{/}
</div>