- 移除 AccountController 中的密码登录重定向逻辑 - 在 Login.cshtml 视图中添加 DisablePasswordLogin 和 SSO 配置检测 - 根据配置动态显示 SSO 登录或常规登录表单 - 当禁用密码登录时显示 SSO 单点登录按钮 - 移除退出登录时的密码登录禁用判断逻辑
166 lines
7.3 KiB
Plaintext
166 lines
7.3 KiB
Plaintext
@model LogOnModel
|
|
|
|
@{
|
|
Layout = null;
|
|
ViewBag.Title = "登录";
|
|
var captchaUrl = Url.Action("Captcha") + "?sid=" + Model.SID;
|
|
Model.LoadTime = DateTime.Now;
|
|
var disablePasswordLogin = PS.Config?.ErpElement?.DisablePasswordLogin ?? false;
|
|
var ssoEnable = YLErp.Web.Models.GeneralSSOConfig.Enable;
|
|
}
|
|
|
|
<!DOCTYPE html>
|
|
<html style="height:100%">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>@GlobalConfig.ProjectTitle</title>
|
|
<link rel="stylesheet" href="~/statics/bundles/bundle.min.css?v=@(HtmlUtil.JsVersion)">
|
|
<style>
|
|
.login-container { position: relative; width: 100%; height: 100%; background-image: url(../../Statics/images/loginBackgroundImag.jpg); background-repeat: no-repeat; background-size: cover; }
|
|
.ms-title { width: 100%; line-height: 50px; text-align: center; font-size: 20px; color: #fff; border-bottom: 1px solid #ddd }
|
|
.ms-login { position: absolute; left: 50%; top: 50%; width: 350px; margin: -190px 0 0 -175px; border-radius: 5px; background: rgba(0,1,11,.32); overflow: hidden }
|
|
.ms-content { padding: 30px }
|
|
.login-table { width: 100%; }
|
|
.login-table td { padding-bottom: 10px; }
|
|
.login-input { width: 100% !important; height: 33.5px !important; text-align: left !important; }
|
|
.login-btn { text-align: center; margin-bottom: 18px; height: 36px; width: 100%; }
|
|
.btn-secondary { background-color: #6c757d; border-color: #6c757d; }
|
|
.btn-secondary:hover { background-color: #5a6268; border-color: #545b62; }
|
|
</style>
|
|
<script src="~/Statics/libs/jquery/jquery-3.5.1.min.js"></script>
|
|
<script>
|
|
$(function(){
|
|
CaptchaClick();
|
|
})
|
|
function CaptchaClick(){
|
|
var img = document.getElementById('captcha');
|
|
var newSrc = '@captchaUrl' + '&t=' + new Date().getTime();
|
|
img.setAttribute('src', newSrc);
|
|
}
|
|
</script>
|
|
</head>
|
|
<body style="height:100%">
|
|
<div class="login-container">
|
|
<div class="login-top">
|
|
<div class="login-logo">
|
|
@switch (YLErp.PS.Config.Company)
|
|
{
|
|
case YLErp.Configuration.CompanyEnum.申万:
|
|
<img src="/Images/sywg/maincenter.png" style="width: 300px;" />
|
|
break;
|
|
default:
|
|
<img src="/Images/loginlogo.png" style="height:150px" />
|
|
break;
|
|
}
|
|
</div>
|
|
</div>
|
|
<div class="ms-login">
|
|
<div class="ms-title">@GlobalConfig.ProjectTitle</div>
|
|
@if (disablePasswordLogin)
|
|
{
|
|
<!-- 禁用密码登录,只显示SSO按钮 -->
|
|
<div class="ms-content" style="text-align: center; padding: 40px 30px;">
|
|
<p style="color: #fff; margin-bottom: 20px;">请使用SSO单点登录</p>
|
|
@if (ssoEnable)
|
|
{
|
|
<a href="@YLErp.Web.Models.GeneralSSOConfig.AuthUrl" class="btn btn-primary login-btn" style="background-color: #1890ff; border-color: #1890ff;">SSO单点登录</a>
|
|
}
|
|
else
|
|
{
|
|
<p style="color: #ff6b6b;">SSO登录未配置,请联系管理员</p>
|
|
}
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<!-- 正常登录表单 -->
|
|
<form id="form1" action="/Account/LoginHandle?g=@(Guid.NewGuid())" method="post" class="ms-content">
|
|
<input type="hidden" name="SID" value="@(Model.SID)" />
|
|
<input type="hidden" name="UserName" id="UserName" />
|
|
<input type="hidden" name="Password" id="Password" />
|
|
<input type="hidden" name="LoadTime" value="@(Model.LoadTime.ToString("yyyy-MM-dd HH:mm:ss"))" />
|
|
|
|
<table class="login-table">
|
|
<colgroup>
|
|
<col span="1" width="30" />
|
|
</colgroup>
|
|
<tr>
|
|
<td><img src="~/Images/username.png" /></td>
|
|
<td><input type="text" class="form-control login-input" id="UserName2" placeholder="用户名" autocomplete="off" /></td>
|
|
</tr>
|
|
<tr>
|
|
<td><img src="~/Images/password.png" /></td>
|
|
<td>
|
|
<!--阻止chrome浏览器自动填充-->
|
|
<input type="password" style="display:none" />
|
|
<input type="password" class="form-control login-input" id="Password2" placeholder="密码" autocomplete="new-password" />
|
|
</td>
|
|
</tr>
|
|
@if (Model.NeedCaptcha)
|
|
{
|
|
<tr>
|
|
<td></td>
|
|
<td>
|
|
<input type="text" name="CaptchaCode" id="CaptchaCode" class="form-control login-input mb-2" placeholder="输入验证码" autocomplete="off" />
|
|
<img onclick="CaptchaClick()" style="cursor:pointer;" id="captcha" />
|
|
</td>
|
|
</tr>
|
|
}
|
|
<tr>
|
|
<td></td>
|
|
<td>
|
|
<p id="errMsg" style="color:red;">@Html.Raw(Model?.ErrorMessage)</p>
|
|
<button id="sbumitbtn" type="submit" class="btn btn-primary login-btn">登 录</button>
|
|
@if (ssoEnable)
|
|
{
|
|
<a href="@YLErp.Web.Models.GeneralSSOConfig.AuthUrl" class="btn btn-secondary login-btn" target="_blank">SSO单点登录</a>
|
|
}
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
}
|
|
<div style="text-align:center;margin-bottom:1rem">
|
|
Copyright © 2020 YieldChain All rights reserved.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="display:none">@(Model.Exception?.ToString())</div>
|
|
|
|
<script>
|
|
|
|
function encode(content) {
|
|
var result = [];
|
|
for (var i = 0; i < content.length; i++) {
|
|
result.push(content.charCodeAt(i));
|
|
}
|
|
return btoa(result);
|
|
}
|
|
|
|
function onSubmit() {
|
|
var userName = $('#UserName2').val();
|
|
var password = $('#Password2').val();
|
|
if (!userName || !password) {
|
|
$('#errMsg').text('用户名和密码必须填写');
|
|
return false;
|
|
}
|
|
if ($('#CaptchaCode').length && !$('#CaptchaCode').val()) {
|
|
$('#errMsg').text('请填写验证码');
|
|
return false;
|
|
}
|
|
$('#UserName').val(encode(userName));
|
|
$('#Password').val(encode(password));
|
|
return true;
|
|
}
|
|
|
|
$(function () {
|
|
$('#form1').on('submit', onSubmit);
|
|
});
|
|
|
|
window.history.replaceState(null, null, "/Account/Login?g=@(Guid.NewGuid())");
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|