Skip to content
This repository has been archived by the owner on Oct 5, 2024. It is now read-only.

Change endpoints to use oidc at OW4 #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion app/src/common/constants.example.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const BASE = 'https://online.ntnu.no/';
export const API_BASE = `${BASE}api/v1/`;
export const API_AUTH = 'auth/';
export const API_AUTH = 'openid/token';
export const API_USERS = 'usersaldo/';
export const API_INVENTORY = 'inventory/';
export const API_RFID = 'rfid/';
Expand Down
12 changes: 6 additions & 6 deletions app/src/services/net/http.service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Observable, Subject } from 'rxjs';

import { API_BASE, API_AUTH, CLIENT_SECRET, CLIENT_ID } from 'common/constants';
import { BASE, API_AUTH, CLIENT_SECRET, CLIENT_ID } from 'common/constants';

export class HttpServiceProvider {
constructor(storage) {
Expand Down Expand Up @@ -41,7 +41,7 @@ export class HttpServiceProvider {
if (!this.waitingForToken) {
this.waitingForToken = true;
// Request new token
this.post(`${API_BASE}${API_AUTH}`, {
this.post(`${BASE}${API_AUTH}`, {
client_secret: CLIENT_SECRET,
client_id: CLIENT_ID,
grant_type: 'client_credentials',
Expand Down Expand Up @@ -95,9 +95,9 @@ export class HttpServiceProvider {
* @param {Request} url
* @return Observable<{}>
*/
request(request, clone, usetoken=true) {
request(request, clone, usetoken = true) {
// Add token to request
if(usetoken){
if (usetoken) {
request.headers.set('Authorization', `Bearer ${this.auth_token}`);
}
const resolver = new Subject();
Expand All @@ -110,7 +110,7 @@ export class HttpServiceProvider {
* @param {params} {key: value}
* @return Observable<{}>
*/
get(url, params, usetoken=true) {
get(url, params, usetoken = true) {
let pUrl = url;
if (params) {
pUrl += HttpServiceProvider.urlEncode(params);
Expand All @@ -137,7 +137,7 @@ export class HttpServiceProvider {
* @param {boolean} urlEncoded
* @return Observable<{}>
*/
post(url, body, urlEncoded, usetoken=true) {
post(url, body, urlEncoded, usetoken = true) {
let pUrl = url;
let pBody = body;
const headers = new Headers();
Expand Down