Skip to content

Commit 07a4138

Browse files
committed
Fix msg for recovery code
1 parent b99c728 commit 07a4138

7 files changed

Lines changed: 33 additions & 9 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.1.15-beta.2",
2+
"version": "1.1.15-beta.5",
33
"license": "MIT",
44
"main": "dist/index.js",
55
"typings": "dist/index.d.ts",

src/components/AuthorizerTOTPScanner.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const AuthorizerTOTPScanner: FC<{
3939
phone_number,
4040
urlProps,
4141
}}
42+
is_totp
4243
/>
4344
);
4445
}

src/components/AuthorizerVerifyOtp.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ export const AuthorizerVerifyOtp: FC<{
116116
useEffect(() => {
117117
if (formData.otp === '') {
118118
setErrorData({ ...errorData, otp: 'OTP is required' });
119-
} else if (formData.otp && !isValidOtp(formData.otp)) {
120-
setErrorData({ ...errorData, otp: 'Please enter valid OTP' });
121119
} else {
122120
setErrorData({ ...errorData, otp: null });
123121
}
@@ -161,6 +159,15 @@ export const AuthorizerVerifyOtp: FC<{
161159
{errorData.otp && (
162160
<div className={styles['form-input-error']}>{errorData.otp}</div>
163161
)}
162+
{is_totp && (
163+
<Message
164+
type={MessageType.Info}
165+
text={`If you have lost access to your device, please enter recovery code that were shared while enabling Multifactor Authentication.`}
166+
extraStyles={{
167+
color: 'var(--authorizer-text-color)',
168+
}}
169+
/>
170+
)}
164171
</div>
165172
<br />
166173
<StyledButton

src/components/Message.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ type Props = {
88
type: MessageType;
99
text: string;
1010
onClose?: () => void;
11+
extraStyles?: Record<string, string>;
1112
};
1213

13-
export const Message: FC<Props> = ({ type, text, onClose }) => {
14+
export const Message: FC<Props> = ({ type, text, extraStyles, onClose }) => {
1415
if (text.trim()) {
1516
return (
16-
<StyledMessageWrapper type={type}>
17+
<StyledMessageWrapper type={type} styles={extraStyles}>
1718
<StyledFlex alignItems="center" justifyContent="space-between">
1819
<div style={{ flex: 1 }}>{capitalizeFirstLetter(text)}</div>
1920
{onClose && (

src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export enum ButtonAppearance {
1212
export enum MessageType {
1313
Error,
1414
Success,
15+
Info,
1516
}
1617

1718
export enum AuthorizerProviderActionType {

src/styledComponents/StyledMessageWrapper.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,34 @@ import React, { ReactNode } from 'react';
22
import { MessageType } from '../constants';
33
import styles from '../styles/default.css';
44

5+
const getBackgroundColor = (type: MessageType): string => {
6+
switch (type) {
7+
case MessageType.Error:
8+
return 'var(--authorizer-danger-color)';
9+
case MessageType.Success:
10+
return 'var(--authorizer-success-color)';
11+
case MessageType.Info:
12+
return 'var(--authorizer-slate-color)';
13+
default:
14+
return 'var(--authorizer-success-color)';
15+
}
16+
};
17+
518
const StyledMessageWrapper = ({
619
type = MessageType.Success,
20+
styles: extraStyles = {},
721
children,
822
}: {
923
type: MessageType;
1024
children: ReactNode;
25+
styles?: Record<string, string>;
1126
}) => {
1227
return (
1328
<div
1429
className={styles['styled-message-wrapper']}
1530
style={{
16-
backgroundColor:
17-
type === MessageType.Error
18-
? 'var(--authorizer-danger-color)'
19-
: 'var(--authorizer-success-color)',
31+
backgroundColor: getBackgroundColor(type),
32+
...extraStyles,
2033
}}
2134
>
2235
{children}

src/styles/default.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
--authorizer-primary-color: #3b82f6;
33
--authorizer-primary-disabled-color: #60a5fa;
44
--authorizer-gray-color: #d1d5db;
5+
--authorizer-slate-color: #e2e8f0;
56
--authorizer-white-color: #ffffff;
67
--authorizer-danger-color: #dc2626;
78
--authorizer-success-color: #10b981;

0 commit comments

Comments
 (0)