Skip to content

Commit

Permalink
Add ability to override redirectUrl in swagger-oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen1 committed Mar 24, 2015
1 parent 5375e9e commit 9922da7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/swagger-oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ function handleLogin() {
var authSchemes = window.swaggerUi.api.authSchemes;
var host = window.location;
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl;
var url = null;

for (var key in authSchemes) {
Expand Down
4 changes: 4 additions & 0 deletions swagger-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ window.SwaggerUi = Backbone.Router.extend({
];
}

if (typeof options.redirectUrl === 'string') {
window.oAuthRedirectUrl = options.redirectUrl;
}

// Create an empty div which contains the dom_id
if (! $('#' + this.dom_id).length){
$('body').append('<div id="' + this.dom_id + '"></div>') ;
Expand Down
Loading

0 comments on commit 9922da7

Please sign in to comment.