Skip to content

Commit bc005ef

Browse files
feat(react): Improvements to Identifier first authenticator in the React SDK
1 parent f697c5f commit bc005ef

File tree

14 files changed

+168
-13
lines changed

14 files changed

+168
-13
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export const common: Common = {
2424
error: 'Something went wrong. Please try again.',
2525
'multiple.options.prefix': 'Sign in with',
2626
or: 'OR',
27-
'prefix.register': "Don't have an account?",
27+
'prefix.register': "Don't have an account? ",
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/fragments/BasicAuth.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ const BasicAuth = ({
4646
showSelfSignUp,
4747
renderLoginOptions,
4848
}: BasicAuthProps): ReactElement => {
49-
const [username, setUsername] = useState<string>('');
5049
const [password, setPassword] = useState<string>('');
5150

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

5453
const {t, isLoading} = useTranslations({
5554
componentLocaleOverride: brandingProps?.locale,
@@ -114,8 +113,6 @@ const BasicAuth = ({
114113
password,
115114
username,
116115
});
117-
setUsername('');
118-
setPassword('');
119116
}}
120117
>
121118
{t(keys.login.button)}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ const IdentifierFirst = ({
4646
showSelfSignUp,
4747
renderLoginOptions,
4848
}: BasicAuthProps): ReactElement => {
49-
const [username, setUsername] = useState<string>('');
50-
51-
const {isAuthLoading} = useContext(AsgardeoContext);
49+
const {isAuthLoading, username, setUsername} = useContext(AsgardeoContext);
5250

5351
const {t, isLoading} = useTranslations({
5452
componentLocaleOverride: brandingProps?.locale,
@@ -101,7 +99,6 @@ const IdentifierFirst = ({
10199
handleAuthenticate(authenticator.authenticatorId, {
102100
username,
103101
});
104-
setUsername('');
105102
}}
106103
>
107104
{t(keys.login.button)}

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

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

1919
import {ReactElement} from 'react';
20+
import buildingIcon from '../../../assets/building-icon.svg';
2021
import emailSolid from '../../../assets/email-solid.svg';
2122
import smsIcon from '../../../assets/sms-icon.svg';
2223
import facebook from '../../../assets/social-logins/facebook.svg';
@@ -55,7 +56,7 @@ const LoginOptionsBox = ({
5556
<UISignIn.Button
5657
className={`Button-${socialName.toLowerCase()}`}
5758
social
58-
startIcon={<img className="social-login-img" src={images[socialName]} alt={socialName} />}
59+
startIcon={<img className="social-login-img" src={images[socialName] ?? buildingIcon} alt={socialName} />}
5960
onClick={handleOnClick}
6061
disabled={isAuthLoading}
6162
>

0 commit comments

Comments
 (0)