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

TMSS-937 - Updated the UI constant

parent 1ad76348
No related branches found
No related tags found
2 merge requests!634WIP: COBALT commissioning delta,!577Resolves TMSS-937
......@@ -9,7 +9,7 @@ const axios = require('axios');
const Auth = {
/** To check if user already logged in
* - 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
*/
isAuthenticated: async () => {
......@@ -19,7 +19,7 @@ const Auth = {
return Auth.getUserPermission(user);
} else {
//Keycloak authendication
const res = await AuthService.keycloakAuthenticate();
const res = await AuthService.getKeycloakAuthState();
if (res && res.is_authenticated) {
localStorage.setItem("loginType", 'Keycloak');
const cookies = document.cookie.split(';').reduce((prev, current) => {
......
......@@ -9,6 +9,9 @@ import UIConstants from '../utils/ui.constants';
* Component to authenticate users in the application.
*/
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){
super(props);
this.state = {
......@@ -80,21 +83,21 @@ export class Login extends Component {
* @param {*}
*/
async doKeyCloakLogin(e) {
window.location.href = UIConstants.KEYCLOAK_AUTH_URL;
window.location.href = this.KEYCLOAK_AUTH_URL;
}
/**
* Redirect to forget password page
*/
async forgetPassword() {
window.location.href = UIConstants.FORGET_PASSWORD_URL;
window.location.href = this.FORGET_PASSWORD_URL;
}
/**
* Redirect to Request access page
*/
async requestAccess() {
window.location.href = UIConstants.REQUEST_ACCESS_URL;
window.location.href = this.REQUEST_ACCESS_URL;
}
render() {
......
import UIConstants from '../utils/ui.constants';
const axios = require('axios');
const AuthService = {
......@@ -14,13 +12,17 @@ const AuthService = {
return null;
}
},
keycloakAuthenticate: async() => {
/**
* Get keycloak auth state
* @returns auth state in JSON
*/
getKeycloakAuthState: async() => {
try {
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;
} catch(error) {
console.error('Error [keycloakAuthenticate]',error);
console.error('Error [getKeycloakAuthState]',error);
return null;
}
},
......@@ -45,7 +47,7 @@ const AuthService = {
}
contentType = axios.defaults.headers.common['Content-Type'];
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',
}});
}
......
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"},
timeline: {
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