Skip to content

Commit

Permalink
Merge pull request #1857 from Expensify/jasper-setPasswordEmailLink
Browse files Browse the repository at this point in the history
Add accountID to the set password link
  • Loading branch information
marcaaron authored Apr 7, 2021
2 parents c8d4389 + 1ba8ca8 commit 5869e17
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {
IOU_BILL: 'iou/split',
SEARCH: 'search',
SIGNIN: 'signin',
SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:validateCode',
SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:accountID/:validateCode',
DETAILS: 'details',
DETAILS_WITH_LOGIN: 'details/:login',
getDetailsRoute: login => `details/${login}`,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,12 @@ function ResetPassword(parameters) {
* @param {Object} parameters
* @param {String} parameters.password
* @param {String} parameters.validateCode
* @param {String} parameters.accountID
* @returns {Promise}
*/
function SetPassword(parameters) {
const commandName = 'SetPassword';
requireParameters(['email', 'password', 'validateCode'], parameters, commandName);
requireParameters(['accountID', 'password', 'validateCode'], parameters, commandName);
return Network.post(commandName, parameters);
}

Expand Down
8 changes: 4 additions & 4 deletions src/libs/actions/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,19 @@ function restartSignin() {
*
* @param {String} password
* @param {String} validateCode
* @param {String} accountID
*/
function setPassword(password, validateCode) {
function setPassword(password, validateCode, accountID) {
Onyx.merge(ONYXKEYS.ACCOUNT, {error: '', loading: true});

API.SetPassword({
email: credentials.login,
password,
validateCode,
accountID,
})
.then((response) => {
if (response.jsonCode === 200) {
const {authToken, email} = response;
createTemporaryLogin(authToken, email);
createTemporaryLogin(response.authToken, response.email);
return;
}

Expand Down
12 changes: 11 additions & 1 deletion src/pages/SetPasswordPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ const propTypes = {
password: PropTypes.string,
}),

// The accountID and validateCode are passed via the URL
route: PropTypes.shape({
// Each parameter passed via the URL
params: PropTypes.shape({
// The user's accountID
accountID: PropTypes.string,

// The user's validateCode
validateCode: PropTypes.string,
}),
}),
Expand Down Expand Up @@ -78,7 +84,11 @@ class SetPasswordPage extends Component {
this.setState({
formError: null,
});
setPassword(this.state.password, lodashGet(this.props.route, 'params.validateCode', ''));
setPassword(
this.state.password,
lodashGet(this.props.route, 'params.validateCode', ''),
lodashGet(this.props.route, 'params.accountID', ''),
);
}

render() {
Expand Down

0 comments on commit 5869e17

Please sign in to comment.