Skip to content

Commit

Permalink
Re-implemented authentication modal
Browse files Browse the repository at this point in the history
  • Loading branch information
dallonf committed Jul 17, 2012
1 parent de9a662 commit 3324be3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
5 changes: 3 additions & 2 deletions public/js/app/app.js
Expand Up @@ -6,6 +6,7 @@ var App = Backbone.Model.extend({
defaults: {
appName: 'My App'
, appUrl: ''
, authKey: true
, resourceType: ''
, files: undefined
}
Expand All @@ -16,15 +17,15 @@ var App = Backbone.Model.extend({
this.on('change:authKey', function() {
var authKey = this.get('authKey');
if (authKey) {
$.cookie('DPDAuthKey', authKey, {expires: 7});
$.cookie('DPDAuthKey', authKey, {expires: 31});
} else {
$.cookie('DPDAuthKey', null);
}
}, this);

this.set({
appUrl: location.protocol + '//' + location.host
, authKey: $.cookie('DPDAuthKey')
, authKey: $.cookie('DPDAuthKey') || true
});
this.setDocLink();
}
Expand Down
2 changes: 1 addition & 1 deletion public/js/app/backbone-utils.js
Expand Up @@ -42,7 +42,7 @@ Backbone.sync = function(method, model, options) {
}

options.headers = {
'dpd-ssh-key': true
'dpd-ssh-key': app.get('authKey') || true
};

options.url = options.url || url;
Expand Down
14 changes: 7 additions & 7 deletions public/js/app/view/app-view.js
Expand Up @@ -27,20 +27,20 @@ define(function(require, exports, module) {

this.authenticate();
this.resources.fetch();
// app.on('change:authKey', this.authenticate, this);
app.on('change:authKey', this.authenticate, this);
this.resources.on('reset', this.initRender, this);
this.resources.on('error', this.modal.showError, this.modal);
}

, authenticate: function() {

this.resources.fetch();
// this.resources.fetch();

// if (app.get('authKey')) {
// this.resources.fetch();
// } else {
// this.modal.show();
// }
if (app.get('authKey')) {
this.resources.fetch();
} else {
this.modal.show();
}

}

Expand Down
4 changes: 2 additions & 2 deletions views/templates/auth-modal.ejs
Expand Up @@ -2,8 +2,8 @@
<h3>Deployd Dashboard</h3>
</div>
<div class="modal-body">
<div class="alert alert-error key-error hide">Your auth key is invalid. You can generate a new key with the <code>dpd key</code> command.</div>
<p>Authenticate with your deployd app:</p>
<div class="alert alert-info">If you don't know your key, use <code>dpd remote</code> to authenticate.</div>
<p>Authenticate with your deployd dashboard:</p>
<form>
<label>Authentication key: <textarea class="full-width" rows="6" name="key"></textarea></label>
</form>
Expand Down

0 comments on commit 3324be3

Please sign in to comment.