mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
More work on the combined login
This commit is contained in:
parent
5822505189
commit
964c120798
7 changed files with 457 additions and 10 deletions
|
@ -41,12 +41,12 @@
|
|||
@if (Model.UsePassword)
|
||||
{
|
||||
<input type="checkbox" id="UsePassword" name="UsePassword" checked="checked">
|
||||
<label for="UsePassword">Require users to login with their passwords</label>
|
||||
<label id="passLabel" for="UsePassword">Require users to login with their passwords</label>
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="checkbox" id="UsePassword" name="UsePassword">
|
||||
<label for="UsePassword">Require users to login with their passwords</label>
|
||||
<label id="passLabel" for="UsePassword">Require users to login with their passwords</label>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
@ -84,6 +84,9 @@
|
|||
|
||||
var base = '@Html.GetBaseUrl()';
|
||||
|
||||
|
||||
|
||||
changeDisabledStatus($('#UsePassword'), @Model.UserAuthentication.ToString().ToLower(), $('#passLabel'));
|
||||
if ($('#PlexAuthToken')) {
|
||||
loadUserList();
|
||||
}
|
||||
|
@ -94,7 +97,21 @@
|
|||
});
|
||||
|
||||
|
||||
$('#mainForm').on('click', '#userAuth', function () {
|
||||
var checked = this.checked;
|
||||
changeDisabledStatus($('#UsePassword'), checked, $('#passLabel'));
|
||||
});
|
||||
|
||||
function changeDisabledStatus($element, checked, $label) {
|
||||
if (checked) {
|
||||
$element.removeAttr("disabled");
|
||||
$label.css("color", "");
|
||||
} else {
|
||||
$('#UsePassword').prop('checked', false);
|
||||
$element.attr("disabled", "disabled");
|
||||
$label.css("color", "grey");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function loadUserList() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@*@using StackExchange.Profiling*@
|
||||
@using Ombi.UI.Helpers
|
||||
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase
|
||||
<html>
|
||||
<html id="htmlId">
|
||||
@Html.Partial("Shared/Partial/_Head")
|
||||
|
||||
<body>
|
||||
|
|
17
Ombi.UI/Views/UserLogin/Password.cshtml
Normal file
17
Ombi.UI/Views/UserLogin/Password.cshtml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<form method="POST" id="passwordForm">
|
||||
<input id="dateTimeOffset" name="DateTimeOffset" hidden="hidden" />
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<label> Password </label>
|
||||
</div>
|
||||
<div>
|
||||
<input id="password" class="form-control form-control-custom" name="Password" type="password" placeholder="Password" />
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
|
||||
<button id="passwordBtn" class="btn btn-success-outline" type="submit"><i class="fa fa-user fa-fw"></i> Sign In</button>
|
||||
</form>
|
||||
|
113
Ombi.UI/Views/UserLogin/Username.cshtml
Normal file
113
Ombi.UI/Views/UserLogin/Username.cshtml
Normal file
|
@ -0,0 +1,113 @@
|
|||
@using Ombi.UI.Resources
|
||||
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<Ombi.Core.SettingModels.AuthenticationSettings>
|
||||
|
||||
<div class="home">
|
||||
<h1>@UI.UserLogin_Title</h1>
|
||||
<div>
|
||||
<p>
|
||||
@UI.UserLogin_Paragraph <span title="@UI.UserLogin_Paragraph_SpanHover"><i class="fa fa-question-circle"></i></span>
|
||||
</p>
|
||||
</div>
|
||||
<div id="contentBody">
|
||||
<form method="POST" id="usernameForm">
|
||||
<input id="dateTimeOffset" name="DateTimeOffset" hidden="hidden" />
|
||||
<div>
|
||||
<div>
|
||||
<label>@UI.UserLogin_Username</label>
|
||||
</div>
|
||||
<div>
|
||||
<input id="username" class="form-control form-control-custom" type="text" name="Username" placeholder="@UI.UserLogin_Username_Placeholder" />
|
||||
</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>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
var base = $('#baseUrl').val();
|
||||
|
||||
$('#contentBody').on('click', '#loginBtn', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var url = createBaseUrl(base, '/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);
|
||||
}
|
||||
} 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').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');
|
||||
// Do some sliding?
|
||||
$body.html(html);
|
||||
}
|
||||
|
||||
|
||||
$('#dateTimeOffset').val(new Date().getTimezoneOffset());
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue