Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Clean up OAuth 'authed' view handling

Whacked some cruft on authSuccess DOM appending. Basically, some
cleanup around OAuth UI. TODO: consider loading client ID/secret on
reload if in Redis session.
  • Loading branch information...
commit 95ba54f3f550d989554bc3cb34f248df7df1b16c 1 parent 5be5ffc
@mansilladev mansilladev authored
View
2  public/javascripts/docs.js
@@ -153,6 +153,8 @@
$('#credentials').submit(function(event) {
event.preventDefault();
var params = $(this).serializeArray();
+ $('#oauthAuthenticated').hide();
+ $('section.credentials').removeClass('authed');
if (params[1].name == 'oauth') {
$.post('/auth', params, function(result) {
if (result.signin) {
View
24 public/javascripts/livedocs.js
@@ -41,28 +41,14 @@ var livedocs = (function() {
/**
* Handle OAuth success callback
*/
- ld.authSuccess = function(msg, token) {
- var credentials = $('section.credentials');
+ ld.authSuccess = function(token) {
+ $('#oauthAuthenticated').show();
+ $('section.credentials').addClass('authed');
if (token) {
$('#accessToken').val(token.match(/access_token\=([^&]+)[&]?/)[1]);
- $('h2', credentials).remove();
- $('img', credentials).remove();
-
- credentials
- .addClass('authed')
- .append($(document.createElement('span')).text(msg))
- .append($(document.createElement('img')).attr('src', '/images/accept.png'));
- }
- else {
- $('h2', credentials).remove();
- $('img', credentials).remove();
-
- credentials
- .addClass('authed')
- .append($(document.createElement('span')).text(msg))
- .append($(document.createElement('img')).attr('src', '/images/accept.png'));
}
}
return ld;
-}(livedocs || {}));
+}(livedocs || {}));
+
View
81 views/api.jade
@@ -8,55 +8,50 @@ block content
- else
- var authed =''
-
form#credentials
input(type='hidden', name='apiName', value=apiName)
- if (apiInfo.auth)
- console.log(apiInfo)
section(class='credentials ' + authed)
- - if (authed && apiInfo.oauth)
- span Authenticated with OAuth
- img(src='/images/accept.png')
- - else if (authed && apiInfo.oauth2)
- span Authenticated with OAuth2
- img(src='/images/accept.png')
- - else
- h2 API Credentials
- img(src='/images/key.png')
-
- - if (apiInfo.oauth)
- input(type='hidden', name='oauth', value='authrequired')
- - else if (apiInfo.oauth2)
- input(type='hidden', name='oauth2', value='authrequired')
+ - if (apiInfo.oauth)
+ input(type='hidden', name='oauth', value='authrequired')
+ - else if (apiInfo.oauth2)
+ input(type='hidden', name='oauth2', value='authrequired')
- - if (apiInfo.auth.defaultKey)
- - var defaultKey =apiInfo.auth.defaultKey
- - else
- - var defaultKey =''
+ - if (apiInfo.auth.defaultKey)
+ - var defaultKey =apiInfo.auth.defaultKey
+ - else
+ - var defaultKey =''
- - if (apiInfo.auth.defaultSecret)
- - var defaultSecret =apiInfo.auth.defaultSecret
- - else
- - var defaultSecret =''
- div
- - if (apiInfo.oauth || apiInfo.oauth2)
- label(for='key') Client ID
- - else
- label(for='key') API Key
- input(id='key', name='key', value=defaultKey, style='color=#EEEEEE')
- div
- - if (apiInfo.oauth || apiInfo.oauth2)
- label(for='secret') Client Secret
- input(id='secret', name='secret', value=defaultSecret, style='color=#EEEEEE')
- - else if (apiInfo.signature)
- label(for='secret') Shared Secret
- input(id='secret', name='secret', value=defaultSecret, style='color=#EEEEEE')
- - if (apiInfo.oauth && apiInfo.oauth.type !='two-legged')
- div
- input(name='oauth', value='Authenticate with OAuth', type='submit', id='oauth-auth')
- - else if (apiInfo.oauth2)
- div
- input(name='oauth', value='Authenticate with OAuth2', type='submit', id='oauth-auth')
+ - if (apiInfo.auth.defaultSecret)
+ - var defaultSecret =apiInfo.auth.defaultSecret
+ - else
+ - var defaultSecret =''
+ div
+ - if (apiInfo.oauth || apiInfo.oauth2)
+ label(for='key') Client ID
+ - else
+ label(for='key') API Key
+ input(id='key', name='key', value=defaultKey, style='color=#EEEEEE')
+ div
+ - if (apiInfo.oauth || apiInfo.oauth2)
+ label(for='secret') Client Secret
+ input(id='secret', name='secret', value=defaultSecret, style='color=#EEEEEE')
+ - if (apiInfo.signature)
+ label(for='secret') Shared Secret
+ input(id='secret', name='secret', value=defaultSecret, style='color=#EEEEEE')
+ - if (apiInfo.oauth && apiInfo.oauth.type !='two-legged')
+ div
+ input(name='oauth', value='Authenticate with OAuth', type='submit', id='oauth-auth')
+ - else if (apiInfo.oauth2)
+ div
+ input(name='oauth', value='Authenticate with OAuth2', type='submit', id='oauth-auth')
+ div(id='oauthAuthenticated', style='display:none')
+ br
+ span(style='vertical-align:botttom') Authenticated with OAuth
+ img(src='/images/accept.png')
+ - if (authed && (apiInfo.oauth || apiInfo.oauth2))
+ script.
+ document.getElementById('oauthAuthenticated').style.display = 'block';
div(id='controls')
View
6 views/authSuccess.jade
@@ -3,10 +3,10 @@ block content
h1= title
- if (apiInfo.oauth)
script.
- window.parent.opener.livedocs.authSuccess('Authenticated with OAuth'); //Indicate to the parent page
+ window.parent.opener.livedocs.authSuccess(); //Indicate to the parent page
window.close();
- - else
+ - else (apiInfo.oauth2)
script.
var accToken = window.location.hash;
- window.parent.opener.livedocs.authSuccess('Authenticated with OAuth2', accToken); //Indicate to the parent page
+ window.parent.opener.livedocs.authSuccess(accToken); //Indicate to the parent page
window.close();
Please sign in to comment.
Something went wrong with that request. Please try again.