Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/pages/ValidateLoginPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const propTypes = {
authToken: PropTypes.string,
}),

/** The credentials of the person logging in */
credentials: PropTypes.shape({
/** The email the user logged in with */
login: PropTypes.string,
}),

/** Indicates which locale the user currently has selected */
preferredLocale: PropTypes.string,
};
Expand All @@ -36,14 +42,19 @@ const defaultProps = {
session: {
authToken: null,
},
credentials: {},
preferredLocale: CONST.LOCALES.DEFAULT,
};

class ValidateLoginPage extends Component {
componentDidMount() {
const login = lodashGet(this.props, 'credentials.login', null);
const accountID = lodashGet(this.props.route.params, 'accountID', '');
const validateCode = lodashGet(this.props.route.params, 'validateCode', '');
if (Permissions.canUsePasswordlessLogins(this.props.betas)) {

// A fresh session will not have credentials.login and user permission betas available.
// In that case, we directly allow users to go through password less flow
if (!login || Permissions.canUsePasswordlessLogins(this.props.betas)) {
if (lodashGet(this.props, 'session.authToken')) {
// If already signed in, do not show the validate code if not on web,
// because we don't want to block the user with the interstitial page.
Expand All @@ -68,6 +79,7 @@ export default compose(
withLocalize,
withOnyx({
betas: {key: ONYXKEYS.BETAS},
credentials: {key: ONYXKEYS.CREDENTIALS},
session: {key: ONYXKEYS.SESSION},
}),
)(ValidateLoginPage);
13 changes: 7 additions & 6 deletions src/pages/ValidateLoginPage/index.website.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const propTypes = {
authToken: PropTypes.string,
}),

/** The credentials of the logged in person */
/** The credentials of the person logging in */
credentials: PropTypes.shape({
/** The email the user logged in with */
login: PropTypes.string,
Expand Down Expand Up @@ -61,17 +61,18 @@ const defaultProps = {

class ValidateLoginPage extends Component {
componentDidMount() {
// Validate login if
// - The user is not on passwordless beta
if (!Permissions.canUsePasswordlessLogins(this.props.betas)) {
const login = lodashGet(this.props, 'credentials.login', null);

// A fresh session will not have credentials.login and user permission betas available.
// In that case, we directly allow users to go through password less flow
if (login && !Permissions.canUsePasswordlessLogins(this.props.betas)) {
User.validateLogin(this.getAccountID(), this.getValidateCode());
return;
}

const isSignedIn = Boolean(lodashGet(this.props, 'session.authToken', null));
const cachedAutoAuthState = lodashGet(this.props, 'session.autoAuthState', null);
const login = lodashGet(this.props, 'credentials.login', null);
if (!login && isSignedIn && cachedAutoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN) {
if (!login && isSignedIn && (cachedAutoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN || cachedAutoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN)) {
Comment thread
jjcoffee marked this conversation as resolved.
Resolved
// The user clicked the option to sign in the current tab
Navigation.navigate(ROUTES.REPORT);
return;
Expand Down