Skip to content

Commit 23330bc

Browse files
Merge pull request #34 from DonOmalVindula/implement-identifier-first
feat(react): Improvements to Identifier first authenticator in the React SDK
2 parents 41fc8b2 + 23ad290 commit 23330bc

File tree

21 files changed

+242
-28
lines changed

21 files changed

+242
-28
lines changed

.changeset/calm-deers-hug.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@asgardeo/react": patch
3+
"@asgardeo/js": patch
4+
---
5+
6+
Improvements to Identifier first authenticator in the React SDK

packages/core/src/i18n/screens/common/en-US.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ export const common: Common = {
2828
'privacy.policy': 'Privacy Policy',
2929
register: 'Register',
3030
'site.title': 'WSO2 Identity Server',
31-
'terms.of.service': 'Terms of Servicet',
31+
'terms.of.service': 'Terms of Service',
3232
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
import {IdentifierFirst} from './model';
20+
21+
export const identifierFirst: IdentifierFirst = {
22+
continue: 'Continue',
23+
'enter.your.username': 'Enter your username',
24+
'login.button': 'Sign In',
25+
'login.heading': 'Sign In',
26+
'remember.me': 'Remember me on this computer',
27+
retry: 'Login failed! Please check your username and password and try again.',
28+
username: 'Username',
29+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
import {IdentifierFirst} from './model';
20+
21+
export const identifierFirst: IdentifierFirst = {
22+
continue: 'Continuer',
23+
'enter.your.username': "Entrez votre nom d'utilisateur",
24+
'login.button': 'Se connecter',
25+
'login.heading': 'Se connecter',
26+
'remember.me': 'Se souvenir de moi sur cet ordinateur',
27+
retry: "Échec de la connexion! Veuillez vérifier votre nom d'utilisateur et votre mot de passe et réessayer.",
28+
username: "Nom d'utilisateur",
29+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
/**
20+
* Interface for the IdentifierFirst text.
21+
*/
22+
export interface IdentifierFirst {
23+
continue: string;
24+
'enter.your.username': string;
25+
'login.button': string;
26+
'login.heading': string;
27+
'remember.me': string;
28+
retry: string;
29+
username: string;
30+
}

packages/core/src/i18n/screens/keys.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ interface Keys {
7575
placeholder: string;
7676
};
7777
};
78+
identifierFirst: {
79+
button: string;
80+
continue: string;
81+
enter: {
82+
your: {
83+
username: string;
84+
};
85+
};
86+
login: {
87+
heading: string;
88+
};
89+
remember: {
90+
me: string;
91+
};
92+
retry: string;
93+
username: string;
94+
};
7895
login: {
7996
button: string;
8097
enter: {
@@ -183,6 +200,23 @@ export const keys: Keys = {
183200
placeholder: 'emailOtp.username.placeholder',
184201
},
185202
},
203+
identifierFirst: {
204+
button: 'identifierFirst.button',
205+
continue: 'identifierFirst.continue',
206+
enter: {
207+
your: {
208+
username: 'identifierFirst.enter.your.username',
209+
},
210+
},
211+
login: {
212+
heading: 'identifierFirst.login.heading',
213+
},
214+
remember: {
215+
me: 'identifierFirst.remember.me',
216+
},
217+
retry: 'identifierFirst.retry',
218+
username: 'identifierFirst.username',
219+
},
186220
login: {
187221
button: 'login.login.button',
188222
enter: {

packages/core/src/i18n/screens/model.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
import {Common} from './common/model';
20+
import {IdentifierFirst} from './identifierFirst/model';
2021
import {Login} from './login/model';
2122
import {TOTP} from './totp/model';
2223

@@ -25,11 +26,12 @@ import {TOTP} from './totp/model';
2526
*/
2627
export interface TextPreference {
2728
common: Common;
29+
identifierFirst: IdentifierFirst;
2830
login: Login;
2931
totp: TOTP;
3032
}
3133

3234
/**
3335
* Interface for the return type of the getLocalization function.
3436
*/
35-
export type TextObject = Login | TOTP | Common;
37+
export type TextObject = Login | TOTP | Common | IdentifierFirst;
Lines changed: 25 additions & 0 deletions
Loading

packages/react/src/components/SignIn/SignIn.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,17 @@ import IdentifierFirst from './fragments/IdentifierFirst';
6262
* @returns {ReactElement} - React element.
6363
*/
6464
const SignIn: FC<SignInProps> = (props: SignInProps): ReactElement => {
65-
const {brandingProps, showFooter = true, showLogo = true, showSignUp} = props;
65+
const {
66+
basicAuthChildren,
67+
brandingProps,
68+
emailOtpChildren,
69+
identifierFirstChildren,
70+
showFooter = true,
71+
showLogo = true,
72+
showSignUp,
73+
smsOtpChildren,
74+
totpChildren,
75+
} = props;
6676

6777
const [isComponentLoading, setIsComponentLoading] = useState<boolean>(true);
6878
const [alert, setAlert] = useState<AlertType>();
@@ -231,7 +241,9 @@ const SignIn: FC<SignInProps> = (props: SignInProps): ReactElement => {
231241
(auth: Authenticator) => auth.authenticatorId !== usernamePasswordAuthenticator.authenticatorId,
232242
),
233243
)}
234-
/>
244+
>
245+
{basicAuthChildren}
246+
</BasicAuth>
235247
);
236248
}
237249

@@ -252,7 +264,9 @@ const SignIn: FC<SignInProps> = (props: SignInProps): ReactElement => {
252264
(auth: Authenticator) => auth.authenticatorId !== identifierFirstAuthenticator.authenticatorId,
253265
),
254266
)}
255-
/>
267+
>
268+
{identifierFirstChildren}
269+
</IdentifierFirst>
256270
);
257271
}
258272

@@ -264,7 +278,9 @@ const SignIn: FC<SignInProps> = (props: SignInProps): ReactElement => {
264278
authenticator={authenticators[0]}
265279
alert={alert}
266280
handleAuthenticate={handleAuthenticate}
267-
/>
281+
>
282+
{totpChildren}
283+
</Totp>
268284
);
269285
}
270286
if (
@@ -279,7 +295,9 @@ const SignIn: FC<SignInProps> = (props: SignInProps): ReactElement => {
279295
brandingProps={brandingProps}
280296
authenticator={authenticators[0]}
281297
handleAuthenticate={handleAuthenticate}
282-
/>
298+
>
299+
{emailOtpChildren}
300+
</EmailOtp>
283301
);
284302
}
285303

@@ -295,7 +313,9 @@ const SignIn: FC<SignInProps> = (props: SignInProps): ReactElement => {
295313
brandingProps={brandingProps}
296314
authenticator={authenticators[0]}
297315
handleAuthenticate={handleAuthenticate}
298-
/>
316+
>
317+
{smsOtpChildren}
318+
</SmsOtp>
299319
);
300320
}
301321
}

packages/react/src/components/SignIn/fragments/BasicAuth.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import {ScreenType, keys} from '@asgardeo/js';
2020
import {CircularProgress, Grid, Skeleton} from '@oxygen-ui/react';
21-
import {ReactElement, useContext, useState} from 'react';
21+
import {PropsWithChildren, ReactElement, useContext, useState} from 'react';
2222
import AsgardeoContext from '../../../contexts/asgardeo-context';
2323
import useTranslations from '../../../hooks/use-translations';
2424
import BasicAuthProps from '../../../models/basic-auth-props';
@@ -41,15 +41,15 @@ import './basic-auth.scss';
4141
const BasicAuth = ({
4242
handleAuthenticate,
4343
authenticator,
44+
children,
4445
alert,
4546
brandingProps,
4647
showSelfSignUp,
4748
renderLoginOptions,
48-
}: BasicAuthProps): ReactElement => {
49-
const [username, setUsername] = useState<string>('');
49+
}: PropsWithChildren<BasicAuthProps>): ReactElement => {
5050
const [password, setPassword] = useState<string>('');
5151

52-
const {isAuthLoading} = useContext(AsgardeoContext);
52+
const {isAuthLoading, username, setUsername} = useContext(AsgardeoContext);
5353

5454
const {t, isLoading} = useTranslations({
5555
componentLocaleOverride: brandingProps?.locale,
@@ -103,6 +103,8 @@ const BasicAuth = ({
103103
onChange={(e: React.ChangeEvent<HTMLInputElement>): void => setPassword(e.target.value)}
104104
/>
105105

106+
{children}
107+
106108
<UISignIn.Button
107109
color="primary"
108110
variant="contained"
@@ -114,8 +116,6 @@ const BasicAuth = ({
114116
password,
115117
username,
116118
});
117-
setUsername('');
118-
setPassword('');
119119
}}
120120
>
121121
{t(keys.login.button)}

0 commit comments

Comments
 (0)