You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/Ombi.UI/Views/UserLogin/Username.cshtml

119 lines
4.2 KiB

@using Ombi.UI.Helpers
@using Ombi.UI.Resources
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<Ombi.Core.SettingModels.AuthenticationSettings>
<div class="home">
<h1>@UI.UserLogin_Title</h1>
<div>
<p>
@string.Format(UI.UserLogin_Paragraph, Html.GetMediaServerName().ToHtmlString()).ToString()
</p>
</div>
<div id="contentBody">
<form method="POST" id="usernameForm">
<input id="dateTimeOffset" name="DateTimeOffset" hidden="hidden" />
<div>
<div>
<label>Username</label>
</div>
<div>
<input id="username" class="form-control form-control-custom" type="text" name="Username" placeholder="Username" />
</div>
</div>
<br />
<button id="loginBtn" class="btn btn-success-outline" type="submit"><i class="fa fa-user fa-fw"></i> @UI.UserLogin_SignIn</button>
</form>
</div>
<div id="contentBody2"></div>
</div>
<script>
$(function () {
$('#contentBody').on('click', '#loginBtn', function (e) {
e.preventDefault();
var url = createLocalUrl('/userlogin/login');
var $form = $('#usernameForm');
$.ajax({
type: 'POST',
url: url,
data: $form.serialize(),
dataType: "json",
success: function (response) {
if (response.result === true) {
if (response.usePassword) {
loadArea(response.html);
return $('#dateTimeOffset').val(new Date().getTimezoneOffset());
} else {
return window.location.replace(response.url); // This is probably not uses, it probably goes into the error callback
}
} else if (response.responseText) {
return $('#htmlId').html(response.responseText);
}
else {
return generateNotify(response.message, "warning");
}
},
error: function (e) {
// This is for the CustomModuleExtensions.LoginAndRedirect
// Since it's not a valid JSON return but we are logged in.
// It's a bit hacky, but i've now documented it, so that's okay right?
if (e.status === 200) {
return window.location.reload();
}
console.log(e);
}
});
});
$('#contentBody, #contentBody2').on('click', '#passwordBtn', function (e) {
e.preventDefault();
var url = createBaseUrl(base, '/userlogin/password');
var $form = $('#passwordForm');
$.ajax({
type: 'POST',
url: url,
data: $form.serialize(),
dataType: "json",
success: function (response) {
if (response.result === true) {
window.location.replace(response.url);
} else {
generateNotify(response.message, "warning");
}
},
error: function (e) {
// This is for the CustomModuleExtensions.LoginAndRedirect
// Since it's not a valid JSON return but we are logged in.
// It's a bit hacky, but i've now documented it, so that's okay right?
if (e.status === 200) {
return window.location.reload();
}
console.log(e);
}
});
});
function loadArea(html) {
var $body = $('#contentBody');
var $body2 = $('#contentBody2');
$body2.slideUp();
// Do some sliding?
$body.fadeOut();
$body2.html(html);
$body2.fadeIn();
$body.html("");
}
$('#dateTimeOffset').val(new Date().getTimezoneOffset());
});
</script>