2020-07-09 16:20:32 +01:00
|
|
|
import globalize from 'globalize';
|
|
|
|
|
|
|
|
/* eslint-disable indent */
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function processForgotPasswordResult(result) {
|
|
|
|
if (result.Success) {
|
2020-07-15 09:29:15 +01:00
|
|
|
let msg = globalize.translate('MessagePasswordResetForUsers');
|
2020-05-04 12:44:12 +02:00
|
|
|
msg += '<br/>';
|
|
|
|
msg += '<br/>';
|
|
|
|
msg += result.UsersReset.join('<br/>');
|
2019-11-06 13:43:39 +03:00
|
|
|
return void Dashboard.alert({
|
2018-10-23 01:05:09 +03:00
|
|
|
message: msg,
|
2020-05-04 12:44:12 +02:00
|
|
|
title: globalize.translate('HeaderPasswordReset'),
|
2019-11-06 13:43:39 +03:00
|
|
|
callback: function () {
|
2020-05-04 12:44:12 +02:00
|
|
|
window.location.href = 'index.html';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
Dashboard.alert({
|
2020-05-04 12:44:12 +02:00
|
|
|
message: globalize.translate('MessageInvalidForgotPasswordPin'),
|
|
|
|
title: globalize.translate('HeaderPasswordReset')
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-09 16:20:32 +01:00
|
|
|
export default function (view, params) {
|
2018-10-23 01:05:09 +03:00
|
|
|
function onSubmit(e) {
|
2019-11-06 13:43:39 +03:00
|
|
|
ApiClient.ajax({
|
2020-05-04 12:44:12 +02:00
|
|
|
type: 'POST',
|
|
|
|
url: ApiClient.getUrl('Users/ForgotPassword/Pin'),
|
|
|
|
dataType: 'json',
|
2018-10-23 01:05:09 +03:00
|
|
|
data: {
|
2020-05-04 12:44:12 +02:00
|
|
|
Pin: view.querySelector('#txtPin').value
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
}).then(processForgotPasswordResult);
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
view.querySelector('form').addEventListener('submit', onSubmit);
|
2020-07-15 09:29:15 +01:00
|
|
|
}
|
2020-07-09 16:20:32 +01:00
|
|
|
|
2020-07-15 09:29:15 +01:00
|
|
|
/* eslint-enable indent */
|