Skip to content

Commit

Permalink
Creating common token store and moving email invites and verification…
Browse files Browse the repository at this point in the history
… to it (mattermost#6213)
  • Loading branch information
crspeller authored and jwilander committed Apr 27, 2017
1 parent 0209975 commit ef98deb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
9 changes: 4 additions & 5 deletions actions/user_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,9 @@ export function updatePassword(userId, currentPassword, newPassword, success, er
);
}

export function verifyEmail(uid, hid, success, error) {
export function verifyEmail(token, success, error) {
Client.verifyEmail(
uid,
hid,
token,
(data) => {
if (success) {
success(data);
Expand All @@ -672,9 +671,9 @@ export function verifyEmail(uid, hid, success, error) {
);
}

export function resetPassword(code, password, success, error) {
export function resetPassword(token, password, success, error) {
Client.resetPassword(
code,
token,
password,
() => {
browserHistory.push('/login?extra=' + ActionTypes.PASSWORD_CHANGE);
Expand Down
8 changes: 4 additions & 4 deletions client/client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1319,19 +1319,19 @@ export default class Client {
this.trackEvent('api', 'api_channels_set_active', {channel_id: id});
}

verifyEmail(uid, hid, success, error) {
verifyEmail(token, success, error) {
request.
post(`${this.getUsersRoute()}/verify_email`).
post(`${this.url}/api/v4/users/email/verify`).
set(this.defaultHeaders).
type('application/json').
accept('application/json').
send({uid, hid}).
send({token}).
end(this.handleResponse.bind(this, 'verifyEmail', success, error));
}

resendVerification(email, success, error) {
request.
post(`${this.getUsersRoute()}/resend_verification`).
post(`${this.url}/api/v4/users/email/verify/send`).
set(this.defaultHeaders).
type('application/json').
accept('application/json').
Expand Down
3 changes: 1 addition & 2 deletions components/do_verify_email.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export default class DoVerifyEmail extends React.Component {
}
componentWillMount() {
verifyEmail(
this.props.location.query.uid,
this.props.location.query.hid,
this.props.location.query.token,
() => {
browserHistory.push('/login?extra=verified&email=' + encodeURIComponent(this.props.location.query.email));
},
Expand Down
2 changes: 1 addition & 1 deletion components/password_reset_form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PasswordResetForm extends React.Component {
});

resetPassword(
this.props.location.query.code,
this.props.location.query.token,
password,
() => {
this.setState({error: null});
Expand Down
3 changes: 1 addition & 2 deletions tests/client/client_user.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -655,13 +655,12 @@ describe('Client.User', function() {
TestHelper.initBasic(done, () => {
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
TestHelper.basicClient().verifyEmail(
'junk',
'junk',
function() {
done.fail(new Error('should be invalid'));
},
function(err) {
expect(err.id).toBe('api.context.invalid_param.app_error');
expect(err.id).toBe('api.context.invalid_body_param.app_error');
done();
}
);
Expand Down

0 comments on commit ef98deb

Please sign in to comment.