Skip to content
Snippets Groups Projects
Commit c99acd9b authored by Muthukrishnanmatriot's avatar Muthukrishnanmatriot
Browse files

TMSS-937 - Updated the UI constant

parent 1ad76348
Branches
Tags
2 merge requests!634WIP: COBALT commissioning delta,!577Resolves TMSS-937
...@@ -9,7 +9,7 @@ const axios = require('axios'); ...@@ -9,7 +9,7 @@ const axios = require('axios');
const Auth = { const Auth = {
/** To check if user already logged in /** To check if user already logged in
* - First it will check the API token is available in the browser local storage * - First it will check the API token is available in the browser local storage
* - If not then check the Keycloak authendication * - If not then check the Keycloak authentication
* - Return false if no authentication found * - Return false if no authentication found
*/ */
isAuthenticated: async () => { isAuthenticated: async () => {
...@@ -19,7 +19,7 @@ const Auth = { ...@@ -19,7 +19,7 @@ const Auth = {
return Auth.getUserPermission(user); return Auth.getUserPermission(user);
} else { } else {
//Keycloak authendication //Keycloak authendication
const res = await AuthService.keycloakAuthenticate(); const res = await AuthService.getKeycloakAuthState();
if (res && res.is_authenticated) { if (res && res.is_authenticated) {
localStorage.setItem("loginType", 'Keycloak'); localStorage.setItem("loginType", 'Keycloak');
const cookies = document.cookie.split(';').reduce((prev, current) => { const cookies = document.cookie.split(';').reduce((prev, current) => {
......
...@@ -9,6 +9,9 @@ import UIConstants from '../utils/ui.constants'; ...@@ -9,6 +9,9 @@ import UIConstants from '../utils/ui.constants';
* Component to authenticate users in the application. * Component to authenticate users in the application.
*/ */
export class Login extends Component { export class Login extends Component {
KEYCLOAK_AUTH_URL= '/oidc/authenticate/';
REQUEST_ACCESS_URL= 'https://support.astron.nl/confluence/display/public/TMSS+User+Documentation#TMSSUserDocumentation-Requestaccess';
FORGET_PASSWORD_URL= 'https://webportal.astron.nl/pwm/private/Login';
constructor(props){ constructor(props){
super(props); super(props);
this.state = { this.state = {
...@@ -80,21 +83,21 @@ export class Login extends Component { ...@@ -80,21 +83,21 @@ export class Login extends Component {
* @param {*} * @param {*}
*/ */
async doKeyCloakLogin(e) { async doKeyCloakLogin(e) {
window.location.href = UIConstants.KEYCLOAK_AUTH_URL; window.location.href = this.KEYCLOAK_AUTH_URL;
} }
/** /**
* Redirect to forget password page * Redirect to forget password page
*/ */
async forgetPassword() { async forgetPassword() {
window.location.href = UIConstants.FORGET_PASSWORD_URL; window.location.href = this.FORGET_PASSWORD_URL;
} }
/** /**
* Redirect to Request access page * Redirect to Request access page
*/ */
async requestAccess() { async requestAccess() {
window.location.href = UIConstants.REQUEST_ACCESS_URL; window.location.href = this.REQUEST_ACCESS_URL;
} }
render() { render() {
......
import UIConstants from '../utils/ui.constants';
const axios = require('axios'); const axios = require('axios');
const AuthService = { const AuthService = {
...@@ -14,13 +12,17 @@ const AuthService = { ...@@ -14,13 +12,17 @@ const AuthService = {
return null; return null;
} }
}, },
keycloakAuthenticate: async() => { /**
* Get keycloak auth state
* @returns auth state in JSON
*/
getKeycloakAuthState: async() => {
try { try {
delete axios.defaults.headers.common['Authorization']; delete axios.defaults.headers.common['Authorization'];
const response = await axios.get(UIConstants.KEYCLOAK_AUTHENTICATE_URL); const response = await axios.get('/api/authentication_state/');
return response.data; return response.data;
} catch(error) { } catch(error) {
console.error('Error [keycloakAuthenticate]',error); console.error('Error [getKeycloakAuthState]',error);
return null; return null;
} }
}, },
...@@ -45,7 +47,7 @@ const AuthService = { ...@@ -45,7 +47,7 @@ const AuthService = {
} }
contentType = axios.defaults.headers.common['Content-Type']; contentType = axios.defaults.headers.common['Content-Type'];
const formData = 'csrfmiddlewaretoken='+token; const formData = 'csrfmiddlewaretoken='+token;
await axios.post(UIConstants.KEYCLOAK_LOGOUT_URL, formData, {headers: { await axios.post('/oidc/logout/', formData, {headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
}}); }});
} }
......
const UIConstants = { const UIConstants = {
KEYCLOAK_AUTH_URL: '/oidc/authenticate/',
KEYCLOAK_LOGOUT_URL: '/oidc/logout/',
KEYCLOAK_AUTHENTICATE_URL: '/api/authentication_state/',
REQUEST_ACCESS_URL: 'https://support.astron.nl/confluence/display/public/TMSS+User+Documentation#TMSSUserDocumentation-Requestaccess',
FORGET_PASSWORD_URL: 'https://webportal.astron.nl/pwm/private/Login',
tooltipOptions: {position: 'left', event: 'hover', className:"p-tooltip-custom"}, tooltipOptions: {position: 'left', event: 'hover', className:"p-tooltip-custom"},
timeline: { timeline: {
types: { NORMAL: "NORMAL", WEEKVIEW:"WEEKVIEW"} types: { NORMAL: "NORMAL", WEEKVIEW:"WEEKVIEW"}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment