jellyfin-web/dashboard-ui/scripts/forgotpasswordpin.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-06-17 17:52:04 -07:00
define([], function () {
2016-10-22 22:11:46 -07:00
'use strict';
2016-06-17 17:52:04 -07:00
function processForgotPasswordResult(result) {
if (result.Success) {
var msg = Globalize.translate('MessagePasswordResetForUsers');
msg += '<br/>';
msg += '<br/>';
msg += result.UsersReset.join('<br/>');
Dashboard.alert({
message: msg,
title: Globalize.translate('HeaderPasswordReset'),
callback: function () {
2015-05-16 20:17:23 -07:00
window.location.href = 'login.html';
}
});
return;
}
Dashboard.alert({
message: Globalize.translate('MessageInvalidForgotPasswordPin'),
title: Globalize.translate('HeaderPasswordReset')
});
return;
}
2016-06-17 17:52:04 -07:00
return function (view, params) {
2015-06-07 21:47:19 -07:00
2016-06-17 17:52:04 -07:00
function onSubmit(e) {
2016-06-17 17:52:04 -07:00
ApiClient.ajax({
2016-06-17 17:52:04 -07:00
type: 'POST',
url: ApiClient.getUrl('Users/ForgotPassword/Pin'),
dataType: 'json',
data: {
Pin: view.querySelector('#txtPin').value
}
2015-09-07 09:53:58 -07:00
2016-06-17 17:52:04 -07:00
}).then(processForgotPasswordResult);
2015-09-07 09:53:58 -07:00
2016-06-17 17:52:04 -07:00
e.preventDefault();
return false;
}
2016-06-17 17:52:04 -07:00
view.querySelector('form').addEventListener('submit', onSubmit);
};
});