Skip to content

Commit

Permalink
setup for heroku app
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesward committed Jan 7, 2016
1 parent 769a99c commit 03ec9c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 7 additions & 3 deletions app.js
Expand Up @@ -6,7 +6,7 @@ var hbs = require('hbs');
var app = express();

app.set('view engine', 'hbs');
app.set('trust proxy', 'loopback');
app.enable('trust proxy');

function isSetup() {
return (process.env.CONSUMER_KEY != null) && (process.env.CONSUMER_SECRET != null);
Expand Down Expand Up @@ -66,8 +66,12 @@ app.get('/setup', function(req, res) {
res.redirect('/');
}
else {
var isRemote = (req.hostname.indexOf('localhost') != 0);
res.render('setup', { isRemote: isRemote, oauthCallbackUrl: oauthCallbackUrl(req) });
var isLocal = (req.hostname.indexOf('localhost') == 0);
var herokuApp = null;
if (req.hostname.indexOf('.herokuapp.com') > 0) {
herokuApp = req.hostname.replace(".herokuapp.com", "");
}
res.render('setup', { isLocal: isLocal, oauthCallbackUrl: oauthCallbackUrl(req), herokuApp: herokuApp});
}
});

Expand Down
15 changes: 11 additions & 4 deletions views/setup.hbs
Expand Up @@ -2,7 +2,7 @@

<ol>
<li>
Setup an OAUTH on Salesforce
Setup an OAUTH on Salesforce:
<ol>
<li><a href="https://login.salesforce.com/app/mgmt/forceconnectedapps/forceAppEdit.apexp">Create a new Connected App on Salesforce</a></li>
<li>Fill in the <em>Connected App Name</em>, <em>API Name</em>, and <em>Contact Email</em> fields.</li>
Expand All @@ -12,9 +12,16 @@
</ol>
</li>
<li>
{{#if isRemote}}
Blah
{{else}}
{{#if herokuApp}}
Set the <em>Consumer Key</em> and <em>Consumer Secret</em> values in your Heroku app's config:
<ol>
<li><a href="https://dashboard.heroku.com/apps/{{herokuApp}}/settings" target="_blank">Open your app's settings</a></li>
<li>Click <em>Reveal Config Vars</em></li>
<li>Add a new config var named <code>CONSUMER_KEY</code> with the value of your Connected App's Consumer Key</li>
<li>Add a new config var named <code>CONSUMER_SECRET</code> with the value of your Connected App's Consumer Secret</li>
</ol>
{{/if}}
{{#if isLocal}}
Create a new <code>.env</code> file in the root of your project directory containing the following with your newly created <em>Consumer Key</em> and <em>Consumer Secret</em> values:
<pre><code># DO NOT SHARE THIS FILE OR PUT IT INTO YOUR SCM
CONSUMER_KEY=YOUR_CONSUMER_KEY
Expand Down

0 comments on commit 03ec9c5

Please sign in to comment.