-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: better handling of signin errors 🌱 #1173
- Loading branch information
Showing
15 changed files
with
109 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { FC } from 'react' | ||
import ReactMarkdown from 'react-markdown' | ||
import rehypeRaw from 'rehype-raw' | ||
import rehypeSanitize from 'rehype-sanitize' | ||
import { IMarkdownProps } from './types' | ||
|
||
/** | ||
* Renders markdown text as HTML using ReactMarkdown with plugins | ||
* `rehypeRaw` and `rehypeSanitize`. | ||
* | ||
* @param props - The props for the Markdown component. | ||
*/ | ||
export const Markdown: FC<IMarkdownProps> = (props) => { | ||
return ( | ||
<ReactMarkdown rehypePlugins={[rehypeRaw, rehypeSanitize]}> | ||
{props.text} | ||
</ReactMarkdown> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './Markdown' | ||
export * from './types' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface IMarkdownProps { | ||
text: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.loginError { | ||
margin: 15px 0 0 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
|
||
.text { | ||
margin-bottom: 5px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Markdown } from 'components' | ||
import React from 'react' | ||
import { StyledComponent } from 'types' | ||
import { ILoginErrorProps } from './types' | ||
import styles from './LoginError.module.scss' | ||
import { Button, Caption1 } from '@fluentui/react-components' | ||
import { getFluentIcon } from 'utils' | ||
|
||
export const LoginError: StyledComponent<ILoginErrorProps> = (props) => { | ||
return ( | ||
<div className={LoginError.className}> | ||
<h3 className={styles.text}>{props.text}</h3> | ||
<Caption1 hidden={!props.message}> | ||
<Markdown text={props.message} /> | ||
</Caption1> | ||
|
||
<Button | ||
style={{ marginTop: '1rem' }} | ||
icon={getFluentIcon('Dismiss')} | ||
appearance='subtle' | ||
onClick={() => window.location.replace(window.location.origin)} | ||
> | ||
Dismiss | ||
</Button> | ||
</div> | ||
) | ||
} | ||
|
||
LoginError.displayName = 'LoginError' | ||
LoginError.className = styles.loginError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './LoginError' | ||
export * from './types' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface ILoginErrorProps { | ||
text: string | ||
message?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,20 +27,29 @@ export class SigninError extends Error { | |
} | ||
} | ||
|
||
/** | ||
* No OID found error | ||
*/ | ||
export const NO_OID_FOUND = new SigninError( | ||
'0f8fc199', | ||
'Sorry to break it to you..', | ||
'... but an error occured attempting to sign you in.', | ||
'BlockedSite' | ||
) | ||
|
||
/** | ||
* Tenant not enrolled error | ||
*/ | ||
export const TENANT_NOT_ENROLLED = new SigninError( | ||
'de72e4da', | ||
'Your company is not enrolled in did', | ||
'Please contact<a href="mailto:[email protected]">[email protected]</a> for more information.', | ||
'We\'re currently accepting new pilot customers. Please contact <a href="mailto:[email protected]">[email protected]</a> for more information.', | ||
'Phone' | ||
) | ||
|
||
/** | ||
* User not enrolled error | ||
*/ | ||
export const USER_NOT_ENROLLED = new SigninError( | ||
'cee991f0', | ||
'I promised to keep it a secret...', | ||
|
@@ -49,13 +58,19 @@ export const USER_NOT_ENROLLED = new SigninError( | |
'Sad' | ||
) | ||
|
||
export const SIGNIN_FAILED = new SigninError( | ||
/** | ||
* Generic sign in failed error | ||
*/ | ||
export const GENERIC_SIGNIN_FAILED = new SigninError( | ||
'e0666582', | ||
'An error occured signing you in', | ||
'Sorry, we were not able to sign you in right now, and we are not really sure why!<br/><br/> It can help to clear your browser cache.', | ||
'Dislike' | ||
) | ||
|
||
/** | ||
* User account disabled error | ||
*/ | ||
export const USER_ACCOUNT_DISABLED = new SigninError( | ||
'e0666582', | ||
'An error occured signing you in', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters