Skip to content

Commit

Permalink
fixed issue with scope setting
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jul 17, 2018
1 parent 857b6a3 commit 06c1297
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/js/base/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ ripe.Ripe.prototype.oauth = function(options, callback) {
var clientId = options.clientId || localStorage.getItem("oauth_client_id");
var clientSecret = options.clientSecret || localStorage.getItem("oauth_client_secret");
var redirectUri = options.redirectUri || localStorage.getItem("oauth_redirect_uri");
var scope = options.scope || localStorage.getItem("oauth_scope") || [];
var scope = options.scope || (localStorage.getItem("oauth_scope") || "").split(",") || [];
var oauthToken = options.oauthToken || localStorage.getItem("oauth_token");

scope && localStorage.setItem("oauth_scope", scope.join(","));

if (oauthToken && clientId && clientSecret && redirectUri) {
return this.oauthLogin(
oauthToken,
Expand Down Expand Up @@ -125,7 +127,7 @@ ripe.Ripe.prototype.oauth = function(options, callback) {
function(result) {
if (result) {
localStorage.setItem("oauth_token", result.access_token);
localStorage.setItem("oauth_scope", result.scope);
result.scope && localStorage.setItem("oauth_scope", result.scope.join(","));
this.oauth(callback);
} else {
this.oauth(
Expand Down
4 changes: 2 additions & 2 deletions src/js/ripe-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/js/ripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -1295,9 +1295,11 @@ ripe.Ripe.prototype.oauth = function(options, callback) {
var clientId = options.clientId || localStorage.getItem("oauth_client_id");
var clientSecret = options.clientSecret || localStorage.getItem("oauth_client_secret");
var redirectUri = options.redirectUri || localStorage.getItem("oauth_redirect_uri");
var scope = options.scope || localStorage.getItem("oauth_scope") || [];
var scope = options.scope || (localStorage.getItem("oauth_scope") || "").split(",") || [];
var oauthToken = options.oauthToken || localStorage.getItem("oauth_token");

scope && localStorage.setItem("oauth_scope", scope.join(","));

if (oauthToken && clientId && clientSecret && redirectUri) {
return this.oauthLogin(
oauthToken,
Expand Down Expand Up @@ -1335,7 +1337,7 @@ ripe.Ripe.prototype.oauth = function(options, callback) {
function(result) {
if (result) {
localStorage.setItem("oauth_token", result.access_token);
localStorage.setItem("oauth_scope", result.scope);
result.scope && localStorage.setItem("oauth_scope", result.scope.join(","));
this.oauth(callback);
} else {
this.oauth(
Expand Down
6 changes: 4 additions & 2 deletions src/python/ripe_demo/static/js/ripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -1295,9 +1295,11 @@ ripe.Ripe.prototype.oauth = function(options, callback) {
var clientId = options.clientId || localStorage.getItem("oauth_client_id");
var clientSecret = options.clientSecret || localStorage.getItem("oauth_client_secret");
var redirectUri = options.redirectUri || localStorage.getItem("oauth_redirect_uri");
var scope = options.scope || localStorage.getItem("oauth_scope") || [];
var scope = options.scope || (localStorage.getItem("oauth_scope") || "").split(",") || [];
var oauthToken = options.oauthToken || localStorage.getItem("oauth_token");

scope && localStorage.setItem("oauth_scope", scope.join(","));

if (oauthToken && clientId && clientSecret && redirectUri) {
return this.oauthLogin(
oauthToken,
Expand Down Expand Up @@ -1335,7 +1337,7 @@ ripe.Ripe.prototype.oauth = function(options, callback) {
function(result) {
if (result) {
localStorage.setItem("oauth_token", result.access_token);
localStorage.setItem("oauth_scope", result.scope);
result.scope && localStorage.setItem("oauth_scope", result.scope.join(","));
this.oauth(callback);
} else {
this.oauth(
Expand Down

0 comments on commit 06c1297

Please sign in to comment.