Skip to content

Commit

Permalink
allow providing an access_token in the url
Browse files Browse the repository at this point in the history
  • Loading branch information
kkuepper committed Dec 4, 2024
1 parent e6c14f0 commit 79c11e5
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion common/app/scripts/services/_api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

angular.module('bmmLibApp')
.factory('_api', function ($timeout, $rootScope, _api_queue, $analytics, ngOidcClient, $q) {
.factory('_api', function ($timeout, $rootScope, _api_queue, $analytics, ngOidcClient, $q, $location) {

var factory = {},
oidcUser = {},
Expand Down Expand Up @@ -661,10 +661,38 @@ angular.module('bmmLibApp')

};


factory.loadNewlyCreatedUser =

/** Get the users profile **/
factory.loginUser = function() {
var deferred = $q.defer();

var searchObject = $location.search();
if (searchObject.access_token) {
console.log("basic auth detected");

console.log("bypass login and use provided basic auth token");

oidcUser = {
access_token: searchObject.access_token,
profile: {
"https://members.bcc.no/app_metadata": {
person_id: 1
}
}
};

factory.sendXHR({
method: 'GET',
url: serverUrl+'currentUser'
}, false).then(function(apiUser) {
deferred.resolve(apiUser);
});
return deferred.promise;
}


ngOidcClient.manager.events.addUserLoaded(function(user) {
// Update user when silent renew is triggered
oidcUser = user;
Expand Down

0 comments on commit 79c11e5

Please sign in to comment.