mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Creating common token store and moving email invites and verification to it (#6213)
This commit is contained in:
committed by
Joram Wilander
parent
0e007e344b
commit
9a87bb3af6
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
@@ -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').
|
||||
|
||||
@@ -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));
|
||||
},
|
||||
|
||||
@@ -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});
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user