-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow redirect to MagicLink after Invalid Validation Code #5150
Changes from 6 commits
b10f53f
0a6362e
a1ce081
0ecd7f7
3f1ad9e
745efbb
103bbc5
1e77d15
f278059
8e4f703
a1af035
f25e31f
418c8f6
f42b310
46cd66d
4b4f0ce
e486081
cf0fe90
587948f
0bfaf85
361f097
b1ba7fa
c51f126
c11c337
6180d9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -344,6 +344,8 @@ export default { | |
linkHasBeenResent: 'Link has been re-sent', | ||
weSentYouMagicSignInLink: ({loginType}) => `We've sent a magic sign in link to your ${loginType}.`, | ||
resendLink: 'Resend link', | ||
validationCodeFailedMessage: 'It looks like there was an error with your validation link. Either the validation link has expired, or your account does not exist.', | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove unnecessary line break here. |
||
}, | ||
detailsPage: { | ||
localTime: 'Local time', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ import {View} from 'react-native'; | |
import {withOnyx} from 'react-native-onyx'; | ||
import PropTypes from 'prop-types'; | ||
import _ from 'underscore'; | ||
import Str from 'expensify-common/lib/str'; | ||
import styles from '../../styles/styles'; | ||
import Button from '../../components/Button'; | ||
import Text from '../../components/Text'; | ||
|
@@ -34,6 +33,9 @@ const propTypes = { | |
closed: PropTypes.bool, | ||
}), | ||
|
||
/** Title to be shown in the form */ | ||
titleMessage: PropTypes.string.isRequired, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a couple of issues with this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed with marc on this one. So yeah we agree this variable name does not represent what it is. In your code its translation keys and not a message so its confusing. Let's translate in the parent component so that this remains titleMessage and hence keeps the child component clean. |
||
|
||
...withLocalizePropTypes, | ||
}; | ||
|
||
|
@@ -84,11 +86,7 @@ class ResendValidationForm extends React.Component { | |
<> | ||
<View> | ||
<Text> | ||
{this.props.translate('resendValidationForm.weSentYouMagicSignInLink', { | ||
loginType: (Str.isSMSLogin(this.props.credentials.login) | ||
? this.props.translate('common.phoneNumber').toLowerCase() | ||
: this.props.translate('common.email')).toLowerCase(), | ||
})} | ||
{this.props.titleMessage} | ||
</Text> | ||
</View> | ||
{!_.isEmpty(this.state.formSuccess) && ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ import { | |
} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import lodashGet from 'lodash/get'; | ||
import Str from 'expensify-common/lib/str'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import styles from '../../styles/styles'; | ||
import updateUnread from '../../libs/UnreadIndicatorUpdater/updateUnread/index'; | ||
|
@@ -68,7 +70,8 @@ class SignInPage extends Component { | |
|
||
const validAccount = this.props.account.accountExists | ||
&& this.props.account.validated | ||
&& !this.props.account.forgotPassword; | ||
&& !this.props.account.forgotPassword | ||
&& !this.props.account.validateCodeExpired; | ||
|
||
// Show the password form if | ||
// - A login has been entered | ||
|
@@ -85,7 +88,18 @@ class SignInPage extends Component { | |
// - AND an account did not exist or is not validated for that login | ||
const showResendValidationLinkForm = this.props.credentials.login && !validAccount; | ||
|
||
const welcomeText = this.props.translate(`welcomeText.${showPasswordForm ? 'phrase4' : 'phrase1'}`); | ||
const welcomeText = showResendValidationLinkForm && this.props.account.validateCodeExpired | ||
? '' | ||
: this.props.translate(`welcomeText.${showPasswordForm ? 'phrase4' : 'phrase1'}`); | ||
marcaaron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const validateCodeExpired = lodashGet(this.props.account, 'validateCodeExpired', false); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove unnessary line break. No reason to have two line breaks here. |
||
const resendLinkTitleMessage = this.props.translate(`resendValidationForm.${validateCodeExpired ? 'validationCodeFailedMessage' : 'weSentYouMagicSignInLink'}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think there is too much here. This line is not very readable and it took me a while to understand why loginType is there for I personally feel this would be easier read if written like so, let resendLinkTitleMessage = '';
if (validateCodeExpired) {
resendLinkTitleMessage = this.props.translate('resendValidationForm.validationCodeFailedMessage');
} else if (showResendValidationLinkForm) {
resendLinkTitleMessage = this.props.translate('resendValidationForm.weSentYouMagicSignInLink', {
loginType: (Str.isSMSLogin(this.props.credentials.login)
? this.props.translate('common.phoneNumber').toLowerCase()
: this.props.translate('common.email')).toLowerCase(),
});
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, thanks. I'll update and raise the PR. Somewhere earlier I had seen that we prefer ternary operator over There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, normally we prefer ternary. This situation is a little different though, with the ternary the operations and arguments involved become hard to follow so I feel like if-else is a lot cleaner here. |
||
{ | ||
loginType: (!this.props.credentials.login || Str.isSMSLogin(this.props.credentials.login) | ||
? this.props.translate('common.phoneNumber').toLowerCase() | ||
: this.props.translate('common.email')).toLowerCase(), | ||
}); | ||
|
||
return ( | ||
<> | ||
|
@@ -99,7 +113,7 @@ class SignInPage extends Component { | |
|
||
{showPasswordForm && <PasswordForm />} | ||
|
||
{showResendValidationLinkForm && <ResendValidationForm />} | ||
{showResendValidationLinkForm && <ResendValidationForm titleMessage={resendLinkTitleMessage} />} | ||
</SignInPageLayout> | ||
</SafeAreaView> | ||
</> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which one is it? The account doesn't exist or the validation link has expired? Is there no way to tell the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's any way to identify from the API response I can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, to clarify, I don't think the error makes sense. We are showing it here:
App/src/pages/signin/ResendValidationForm.js
Lines 102 to 103 in 4b4f0ce
Why tell the user the account does not exist? It must exist based on those two conditions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other thing we are looking at is if the account "exists but is not yet validated" a.k.a.
isOldUnvalidatedAccount
- but that doesn't mean the account does not exist.