Skip to content

Commit

Permalink
SAML error page (#582)
Browse files Browse the repository at this point in the history
* add saml error page

* prettier

* update logo

* update logo

* fix issue with error

* make it a page

---------

Co-authored-by: guyp-descope <[email protected]>
Co-authored-by: Omer C <[email protected]>
  • Loading branch information
3 people authored Sep 10, 2024
1 parent 7f0869c commit 6ae6091
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json"
"project": true
},
"plugins": [
"react",
Expand Down
2 changes: 0 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn run format-lint
38 changes: 38 additions & 0 deletions src/SamlError.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import logo from './assets/logo.svg';

const SamlError: React.FC = () => {
let error = 'An error occurred';

const queryParam = new URLSearchParams(window.location.search);
error = queryParam.get('error') || 'An error occurred';

return (
<div className="app-content">
<img
src={logo}
alt="logo"
style={{
marginBottom: '16px'
}}
/>
<h2 className="header-label">Uh-oh, something went wrong</h2>
<div
style={{
marginBottom: '96px'
}}
>
<p
className="text-body1"
style={{
marginTop: '32px'
}}
>
{error}
</p>
</div>
</div>
);
};

export default SamlError;
18 changes: 18 additions & 0 deletions src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import SamlError from './SamlError';

const contentBaseUrl = process.env.REACT_APP_CONTENT_BASE_URL;
if (contentBaseUrl) {
Expand All @@ -10,8 +11,16 @@ if (contentBaseUrl) {
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);

const routerSwitch = (page: string) => {
switch (page) {
case '/login/saml-error':
return <SamlError />;
default:
return <App />;
}
};

root.render(
<React.StrictMode>
<App />
</React.StrictMode>
<React.StrictMode>{routerSwitch(window.location.pathname)}</React.StrictMode>
);

0 comments on commit 6ae6091

Please sign in to comment.