forked from Ivasoft/mattermost-mobile
[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:
@@ -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]}
|
||||
|
||||
2
types/api/config.d.ts
vendored
2
types/api/config.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user