[MM-53249] Allow server to hide or customize the Forgot Password link (#7429)

* [MM-53249] Allow server to hide or customize the Forgot Password link

* Update app/screens/login/form.tsx

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>

* Fix issue for older servers

* Sort imports

---------

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Devin Binnie
2023-07-18 12:31:35 -04:00
committed by GitHub
parent 3effecd6a4
commit 21fc831554
2 changed files with 9 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ import {buttonBackgroundStyle, buttonTextStyle} from '@utils/buttonStyles';
import {getFullErrorMessage, isErrorWithMessage, isServerError} from '@utils/errors';
import {preventDoubleTap} from '@utils/tap';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
import {tryOpenURL} from '@utils/url';
import type {LaunchProps} from '@typings/launch';
@@ -206,6 +207,11 @@ const LoginForm = ({config, extra, serverDisplayName, launchError, launchType, l
}, [error]);
const onPressForgotPassword = useCallback(() => {
if (config.ForgotPasswordLink) {
tryOpenURL(config.ForgotPasswordLink);
return;
}
const passProps = {
theme,
serverUrl,
@@ -334,7 +340,7 @@ const LoginForm = ({config, extra, serverDisplayName, launchError, launchType, l
endAdornment={endAdornment}
/>
{(emailEnabled || usernameEnabled) && (
{(emailEnabled || usernameEnabled) && config.PasswordEnableForgotLink !== 'false' && (
<Button
onPress={onPressForgotPassword}
containerStyle={[styles.forgotPasswordBtn, error ? styles.forgotPasswordError : undefined]}

View File

@@ -121,6 +121,7 @@ interface ClientConfig {
FeatureFlagCollapsedThreads?: string;
FeatureFlagGraphQL?: string;
FeatureFlagPostPriority?: string;
ForgotPasswordLink?: string;
GfycatApiKey: string;
GfycatApiSecret: string;
GoogleDeveloperKey: string;
@@ -147,6 +148,7 @@ interface ClientConfig {
MinimumHashtagLength: string;
OpenIdButtonColor: string;
OpenIdButtonText: string;
PasswordEnableForgotLink: string;
PasswordMinimumLength: string;
PasswordRequireLowercase: string;
PasswordRequireNumber: string;