Skip to content

Commit b237b36

Browse files
authored
Update the value for login type (#9329)
* Update the value for login type * Centralize login type in a constant
1 parent 23fec94 commit b237b36

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

app/constants/sso.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import keyMirror from '@utils/key_mirror';
77
export const REDIRECT_URL_SCHEME = LocalConfig.AuthUrlScheme;
88
export const REDIRECT_URL_SCHEME_DEV = LocalConfig.AuthUrlSchemeDev;
99

10+
export const LOGIN_TYPE = {
11+
MAGIC_LINK: 'magic_link',
12+
EMAIL_PASSWORD: '',
13+
} as const;
14+
1015
const constants = keyMirror({
1116
SAML: null,
1217
GITLAB: null,
@@ -17,6 +22,7 @@ const constants = keyMirror({
1722

1823
export default {
1924
...constants,
25+
...LOGIN_TYPE,
2026
REDIRECT_URL_SCHEME,
2127
REDIRECT_URL_SCHEME_DEV,
2228
};

app/screens/login/form.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import CompassIcon from '@components/compass_icon';
1313
import FloatingTextInput from '@components/floating_input/floating_text_input_label';
1414
import FormattedText from '@components/formatted_text';
1515
import {FORGOT_PASSWORD, MFA} from '@constants/screens';
16+
import {LOGIN_TYPE} from '@constants/sso';
1617
import {useAvoidKeyboard} from '@hooks/device';
1718
import {usePreventDoubleTap} from '@hooks/utils';
1819
import {goToScreen, loginAnimationOptions, resetToHome} from '@screens/navigation';
@@ -45,7 +46,7 @@ function getButtonDisabled(loginId: string, password: string, userLoginType: Log
4546
return true;
4647
}
4748

48-
if (magicLinkEnabled && (userLoginType === 'guest_magic_link' || userLoginType === undefined)) {
49+
if (magicLinkEnabled && (userLoginType === LOGIN_TYPE.MAGIC_LINK || userLoginType === undefined)) {
4950
return false;
5051
}
5152

@@ -248,7 +249,7 @@ const LoginForm = ({
248249
Keyboard.dismiss();
249250
if (magicLinkEnabled && userLoginType === undefined) {
250251
const receivedUserLoginType = await checkUserLoginType();
251-
if (receivedUserLoginType === 'guest_magic_link') {
252+
if (receivedUserLoginType === LOGIN_TYPE.MAGIC_LINK) {
252253
setMagicLinkSent(true);
253254
}
254255
if (isDeactivated) {
@@ -310,7 +311,7 @@ const LoginForm = ({
310311
}, [managedConfig?.username]);
311312

312313
const onIdInputSubmitting = useCallback(() => {
313-
if (!magicLinkEnabled || (userLoginType !== 'guest_magic_link')) {
314+
if (!magicLinkEnabled || (userLoginType !== LOGIN_TYPE.MAGIC_LINK)) {
314315
focusPassword();
315316
return;
316317
}
@@ -319,7 +320,7 @@ const LoginForm = ({
319320
}, [focusPassword, onLogin, magicLinkEnabled, userLoginType]);
320321

321322
const buttonDisabled = getButtonDisabled(loginId, password, userLoginType, isDeactivated, magicLinkEnabled);
322-
const showPasswordInput = !magicLinkEnabled || (userLoginType !== 'guest_magic_link' && userLoginType !== undefined && !isDeactivated);
323+
const showPasswordInput = !magicLinkEnabled || (userLoginType !== LOGIN_TYPE.MAGIC_LINK && userLoginType !== undefined && !isDeactivated);
323324
let userInputError = error;
324325
if (showPasswordInput) {
325326
// error is passed to the password input box, so we use this

types/api/users.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,4 @@ type GetUsersOptions = {
163163
team_roles?: string;
164164
};
165165

166-
type LoginType = '' | 'guest_magic_link';
166+
type LoginType = '' | 'magic_link';

0 commit comments

Comments
 (0)