Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
TokenVaultManagement
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jasonwai
TokenVaultManagement
Commits
a9bea75e
Commit
a9bea75e
authored
Aug 01, 2023
by
nickchen
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 登入時有機率404 & 沒有部門時會出錯
parent
1ad88099
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
UserController.cs
... Vault Management/backstage/Controllers/UserController.cs
+14
-4
Login.cshtml
... Token Vault Management/backstage/Views/User/Login.cshtml
+7
-2
No files found.
Merchant Token Vault Management/backstage/Controllers/UserController.cs
View file @
a9bea75e
...
...
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Authentication;
using
Microsoft.AspNetCore.Authentication.Cookies
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.Configuration
;
using
Newtonsoft.Json
;
...
...
@@ -190,6 +191,7 @@ namespace backstage.Controllers
#
endregion
}
#
region
寫入
TOKEN
int
LoginExpireMinute
=
Convert
.
ToInt32
(
_config
[
"LoginExpireMinute"
]);
...
...
@@ -212,20 +214,22 @@ namespace backstage.Controllers
//將 ClaimsIdentity 設定給 ClaimsPrincipal (持有者)
ClaimsPrincipal
principal
=
new
ClaimsPrincipal
(
userClaims
);
//登入動作
try
{
await
HttpContext
.
SignInAsync
(
CookieAuthenticationDefaults
.
AuthenticationScheme
,
principal
,
new
AuthenticationProperties
()
{
//是否可以被刷新
AllowRefresh
=
true
,
// 設置了一個 1 天 有效期的持久化 cookie
IsPersistent
=
true
,
//IsPersistent = false,瀏覽器關閉即刻登出
//用戶頁面停留太久,逾期時間,在此設定的話會覆蓋Startup.cs裡的逾期設定
//用戶頁面停留太久,逾期時間,在此設定的話會覆蓋Startup.cs裡的逾期設定
ExpiresUtc
=
DateTime
.
Now
.
AddMinutes
(
LoginExpireMinute
),
});
return
RedirectToAction
(
"Index"
,
"Home"
);
}
catch
(
Exception
ex
)
{
...
...
@@ -234,7 +238,7 @@ namespace backstage.Controllers
#
endregion
return
RedirectToAction
(
"Index"
,
"Home"
);
}
else
if
(
u
.
r
==
65796
)
{
...
...
@@ -1107,8 +1111,14 @@ namespace backstage.Controllers
{
return View(DepartmentsResponse);
}*/
var
merchants
=
DepartmentsResponse
.
merchants
.
Where
(
x
=>
x
.
enabled
==
1
).
ToList
();
var
merchants
=
new
List
<
Department
>();
if
(
DepartmentsResponse
.
merchants
!=
null
)
{
merchants
=
DepartmentsResponse
.
merchants
?.
Where
(
x
=>
x
.
enabled
==
1
).
ToList
();
}
return
View
(
merchants
);
}
...
...
Merchant Token Vault Management/backstage/Views/User/Login.cshtml
View file @
a9bea75e
...
...
@@ -57,7 +57,7 @@
}
<div
id=
"msgDiv"
></div>
<!-- <h6 class="font-weight-light">基本資料</h6> -->
<form
class=
"pt-3"
method=
"post"
asp-action=
"login"
asp-route-ReturnUrl=
@Context.Request.Query["ReturnUrl"]
>
<form
id=
"LoginForm"
class=
"pt-3"
method=
"post"
asp-action=
"login"
asp-route-ReturnUrl=
@Context.Request.Query["ReturnUrl"]
>
<div
id=
"errorMsg"
asp-validation-summary=
"All"
class=
"text-danger"
></div>
<div
class=
"form-group"
>
...
...
@@ -70,7 +70,7 @@
<span
asp-validation-for=
"pwd"
class=
"text-danger"
></span>
</div>
<div
class=
"mt-3"
>
<button
type=
"submit"
class=
"btn btn-block btn-gradient-primary btn-lg font-weight-medium"
>
@Localizer["Login"]
</button>
<button
id=
"LoginSubmit"
type=
"submit"
class=
"btn btn-block btn-gradient-primary btn-lg font-weight-medium"
>
@Localizer["Login"]
</button>
</div>
@*
<div
class=
"my-2 d-flex justify-content-between align-items-center"
>
<div
class=
"form-check"
>
...
...
@@ -127,4 +127,9 @@
if
(
msg
!=
''
)
{
showAlert
(
IsSuccess
,
msg
);
}
$
(
'#LoginSubmit'
).
on
(
'click'
,
function
(){
$
(
'#LoginForm'
).
submit
();
this
.
disabled
=
true
;
});
</script>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment