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

65 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-06-17 17:52:04 -07:00
define([], function () {
2016-06-17 17:52:04 -07:00
function processForgotPasswordResult(result) {
if (result.Action == 'ContactAdmin') {
Dashboard.alert({
message: Globalize.translate('MessageContactAdminToResetPassword'),
title: Globalize.translate('HeaderForgotPassword')
});
return;
}
if (result.Action == 'InNetworkRequired') {
Dashboard.alert({
message: Globalize.translate('MessageForgotPasswordInNetworkRequired'),
title: Globalize.translate('HeaderForgotPassword')
});
return;
}
if (result.Action == 'PinCode') {
var msg = Globalize.translate('MessageForgotPasswordFileCreated');
msg += "<br/>";
msg += "<br/>";
msg += result.PinFile;
msg += "<br/>";
Dashboard.alert({
message: msg,
title: Globalize.translate('HeaderForgotPassword')
});
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'),
dataType: 'json',
data: {
EnteredUsername: view.querySelector('#txtName').value
}
2016-06-17 17:52:04 -07:00
}).then(processForgotPasswordResult);
2016-06-17 17:52:04 -07:00
e.preventDefault();
return false;
}
2015-07-27 18:27:00 -07:00
2016-06-17 17:52:04 -07:00
view.querySelector('form').addEventListener('submit', onSubmit);
};
});