mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-03-01 01:40:42 +00:00
fixed guest user access w/ burnettk
This commit is contained in:
parent
74de2063d6
commit
7d086a8580
@ -140,6 +140,11 @@ export const truncateString = (text: string, len: number) => {
|
||||
return text;
|
||||
};
|
||||
|
||||
export const pathFromFullUrl = (fullUrl: string) => {
|
||||
const parsedURL = new URL(fullUrl);
|
||||
return parsedURL.pathname;
|
||||
};
|
||||
|
||||
// Because of limitations in the way openapi defines parameters, we have to modify process models ids
|
||||
// which are basically paths to the models
|
||||
export const modifyProcessIdentifierForPathParam = (path: string) => {
|
||||
|
@ -2,6 +2,7 @@ import jwt from 'jwt-decode';
|
||||
import cookie from 'cookie';
|
||||
import { BACKEND_BASE_URL } from '../config';
|
||||
import { AuthenticationOption } from '../interfaces';
|
||||
import { pathFromFullUrl } from '../helpers';
|
||||
|
||||
// NOTE: this currently stores the jwt token in local storage
|
||||
// which is considered insecure. Server set cookies seem to be considered
|
||||
@ -32,10 +33,14 @@ const getCurrentLocation = (queryParams: string = window.location.search) => {
|
||||
);
|
||||
};
|
||||
|
||||
const checkPathForTaskShowParams = () => {
|
||||
const checkPathForTaskShowParams = (
|
||||
redirectUrl: string = window.location.pathname
|
||||
) => {
|
||||
const path = pathFromFullUrl(redirectUrl);
|
||||
|
||||
// expected url pattern:
|
||||
// /tasks/[process_instance_id]/[task_guid]
|
||||
const pathSegments = window.location.pathname.match(
|
||||
const pathSegments = path.match(
|
||||
/^\/tasks\/(\d+)\/([0-9a-z]{8}-([0-9a-z]{4}-){3}[0-9a-z]{12})$/
|
||||
);
|
||||
if (pathSegments) {
|
||||
@ -48,7 +53,7 @@ const doLogin = (
|
||||
authenticationOption?: AuthenticationOption,
|
||||
redirectUrl?: string | null
|
||||
) => {
|
||||
const taskShowParams = checkPathForTaskShowParams();
|
||||
const taskShowParams = checkPathForTaskShowParams(redirectUrl || undefined);
|
||||
const loginParams = [`redirect_url=${redirectUrl || getCurrentLocation()}`];
|
||||
if (taskShowParams) {
|
||||
loginParams.push(
|
||||
|
Loading…
x
Reference in New Issue
Block a user