Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/access token #94

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 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 @@ -235,6 +235,9 @@ angular.module('bmmLibApp')
};

factory.getAuthorizationHeader = function() {
if (oidcUser.basic_auth) {
return "Basic " + oidcUser.basic_auth;
}
return "Bearer " + oidcUser.access_token;
};

Expand Down Expand Up @@ -661,10 +664,37 @@ angular.module('bmmLibApp')

};


factory.loadNewlyCreatedUser =

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

var searchObject = $location.search();
if (searchObject.basic_auth) {
console.log("basic auth detected");
console.log("bypass login and use provided basic auth token");

oidcUser = {
basic_auth: searchObject.basic_auth,
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
Loading