Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Commit

Permalink
Make exported project respect authentication redirects.
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik Viswanathan committed Aug 31, 2012
1 parent 09acbac commit 1c8cabd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
22 changes: 14 additions & 8 deletions export/index.js
Expand Up @@ -377,20 +377,26 @@ function renderEjsTemplate(template, attributes, screensById) {
template = template.replace( template = template.replace(
/\/share\/#\{session.sharedId\}\/project\/#\{projectId\}\/screen\/#\{screenId\}/g, ''); /\/share\/#\{session.sharedId\}\/project\/#\{projectId\}\/screen\/#\{screenId\}/g, '');


/* Replaces a screen id from a regular expression with a corresponding link. /* Replaces a screen id with its corresponding title slug. Returns a function
* Requires: regular expression match, screen id * that should be used as a regular expression replace callback.
* Returns: corresponding screen link * Requires: format for the replacement string, where %s will be replaced
* with the slug
* Returns: regular expression replace callback assuming that the first
* capture group is the screen id
*/ */
function replaceLink(match, screenId) { function replaceLink(format) {
screenId = parseInt(screenId, 10); return function(match, screenId) {
return '/' + screensById[screenId].titleSlug; screenId = parseInt(screenId, 10);
return format.replace(/%s/g, screensById[screenId].titleSlug);
};
} }


// screen link targets need to be translated to screen routes // screen link targets need to be translated to screen routes
template = template.replace(/\/share\/#\{userId\}\/project\/#\{projectId\}\/screen\/(\d+)/g, template = template.replace(/\/share\/#\{userId\}\/project\/#\{projectId\}\/screen\/(\d+)/g,
replaceLink); replaceLink('/%s'));
template = template.replace(/\/share\/#\{session.sharedId\}\/project\/#\{projectId\}\/screen\/(\d+)/g, template = template.replace(/\/share\/#\{session.sharedId\}\/project\/#\{projectId\}\/screen\/(\d+)/g,
replaceLink); replaceLink('/%s'));
template = template.replace(/\?redirect=(\d+)/, replaceLink('?redirect=%s'));


// no need for unescaped attributes // no need for unescaped attributes
template = template.replace(/!=/g, '='); template = template.replace(/!=/g, '=');
Expand Down
6 changes: 5 additions & 1 deletion views/helpers/share-login-form.jade
@@ -1,5 +1,9 @@
<% if (typeof redirect === 'undefined') { %>
<% redirect = ''; %>
<% } %>

form.login-form(method='post', form.login-form(method='post',
action!="/share/#{userId}/project/#{projectId}/screen/#{screenId}/log-in?redirect=<%= this.redirect || '' %>") action!="/share/#{userId}/project/#{projectId}/screen/#{screenId}/log-in?redirect=<%= redirect %>")
a.persona-button.share-element.auth(href='#log-in') a.persona-button.share-element.auth(href='#log-in')
span Sign in span Sign in
input(type='hidden', name='bid_assertion', value='1') input(type='hidden', name='bid_assertion', value='1')

0 comments on commit 1c8cabd

Please sign in to comment.