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
6bc45117
Commit
6bc45117
authored
Jun 09, 2023
by
alicewang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into alice
parents
49dd4d00
aae9fba7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
11 deletions
+57
-11
HomeController.cs
... Vault Management/backstage/Controllers/HomeController.cs
+1
-1
UserController.cs
... Vault Management/backstage/Controllers/UserController.cs
+56
-10
No files found.
Merchant Token Vault Management/backstage/Controllers/HomeController.cs
View file @
6bc45117
...
@@ -16,7 +16,7 @@ namespace backstage.Controllers
...
@@ -16,7 +16,7 @@ namespace backstage.Controllers
{
{
//
[Authorize]
[
Authorize
]
public
class
HomeController
:
Controller
public
class
HomeController
:
Controller
{
{
...
...
Merchant Token Vault Management/backstage/Controllers/UserController.cs
View file @
6bc45117
...
@@ -96,7 +96,7 @@ namespace backstage.Controllers
...
@@ -96,7 +96,7 @@ namespace backstage.Controllers
string
role
=
""
;
string
role
=
""
;
if
(
user
.
username
==
"theone"
)
if
(
user
.
username
==
"theone"
)
{
{
role
=
"Admin"
;
role
=
"Admin"
;
}
}
else
else
{
{
...
@@ -106,7 +106,7 @@ namespace backstage.Controllers
...
@@ -106,7 +106,7 @@ namespace backstage.Controllers
httpMethod
=
HttpMethod
.
Post
;
httpMethod
=
HttpMethod
.
Post
;
var
types
=
new
[]
{
"admin"
};
var
types
=
new
[]
{
"admin"
};
var
types_data
=
new
{
inc
=
types
};
var
types_data
=
new
{
inc
=
types
};
role
=
"Merchant"
;
role
=
"Merchant"
;
parameters
=
new
Dictionary
<
string
,
string
>
parameters
=
new
Dictionary
<
string
,
string
>
{
{
...
@@ -469,12 +469,13 @@ namespace backstage.Controllers
...
@@ -469,12 +469,13 @@ namespace backstage.Controllers
TempData
[
"msg"
]
=
"發生錯誤"
;
TempData
[
"msg"
]
=
"發生錯誤"
;
return
Redirect
(
"~"
+
returnUrl
);
return
Redirect
(
"~"
+
returnUrl
);
}
}
else
{
else
{
ViewBag
.
returnUrl
=
returnUrl
;
ViewBag
.
returnUrl
=
returnUrl
;
return
View
();
return
View
();
}
}
...
@@ -581,7 +582,11 @@ namespace backstage.Controllers
...
@@ -581,7 +582,11 @@ namespace backstage.Controllers
return
View
();
return
View
();
}
}
/// <summary>
/// 編輯使用者
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
[
Authorize
]
[
Authorize
]
[
HttpPost
]
[
HttpPost
]
public
async
Task
<
IActionResult
>
GetUser
(
User
user
)
public
async
Task
<
IActionResult
>
GetUser
(
User
user
)
...
@@ -643,15 +648,16 @@ namespace backstage.Controllers
...
@@ -643,15 +648,16 @@ namespace backstage.Controllers
if
(
existUserName
.
uid
!=
user
.
uid
)
if
(
existUserName
.
uid
!=
user
.
uid
)
ModelState
.
AddModelError
(
"username"
,
"username重複"
);
ModelState
.
AddModelError
(
"username"
,
"username重複"
);
}
}
if
(!
ModelState
.
IsValid
)
if
(!
ModelState
.
IsValid
)
{
{
return
View
(
user
);
return
View
(
user
);
}
}
//檢查通過
//修改基本資料
existUser
.
name
=
user
.
name
;
existUser
.
name
=
user
.
name
;
existUser
.
username
=
user
.
username
;
existUser
.
username
=
user
.
username
;
//檢查通過
url
=
_config
[
"IP"
]
+
"/user/mod"
;
url
=
_config
[
"IP"
]
+
"/user/mod"
;
...
@@ -668,10 +674,49 @@ namespace backstage.Controllers
...
@@ -668,10 +674,49 @@ namespace backstage.Controllers
{
{
TempData
[
"IsSuccess"
]
=
true
;
TempData
[
"IsSuccess"
]
=
true
;
TempData
[
"msg"
]
=
"編輯成功"
;
TempData
[
"msg"
]
=
"編輯成功"
;
//修改密碼
if
(!
string
.
IsNullOrEmpty
(
user
.
newPassword
))
{
existUser
.
password
=
user
.
newPassword
;
url
=
_config
[
"IP"
]
+
"/user/changepassword"
;
parameters
=
new
Dictionary
<
string
,
string
>
{
{
"token"
,
token
},
{
"oldpwd"
,
user
.
password
},
{
"newpwd"
,
user
.
newPassword
}
};
apiResult
=
await
_callApi
.
CallAPI
(
url
,
parameters
,
httpMethod
);
if
(
apiResult
.
IsSuccess
)
{
var
response
=
JsonConvert
.
DeserializeObject
<
Response
>(
apiResult
.
Data
.
ToString
());
if
(
response
.
r
==
0
)
{
TempData
[
"IsSuccess"
]
=
true
;
TempData
[
"msg"
]
=
"編輯成功"
;
}
else
{
TempData
[
"IsSuccess"
]
=
false
;
TempData
[
"msg"
]
=
response
.
m
;
return
View
();
}
return
RedirectToAction
(
"ListUsers"
);
}
}
return
RedirectToAction
(
"ListUsers"
);
return
RedirectToAction
(
"ListUsers"
);
}
}
TempData
[
"IsSuccess"
]
=
false
;
TempData
[
"IsSuccess"
]
=
false
;
TempData
[
"msg"
]
=
"user_id不存在"
;
TempData
[
"msg"
]
=
"user_id不存在"
;
return
View
(
existUser
);
return
View
(
existUser
);
...
@@ -844,7 +889,7 @@ namespace backstage.Controllers
...
@@ -844,7 +889,7 @@ namespace backstage.Controllers
/// <returns></returns>
/// <returns></returns>
[
Authorize
(
Policy
=
"AdminOnly"
)]
[
Authorize
(
Policy
=
"AdminOnly"
)]
[
HttpPost
]
[
HttpPost
]
public
async
Task
<
ResultModel
>
AdminAddAjax
(
int
uid
,
bool
isAdmin
)
public
async
Task
<
ResultModel
>
AdminAddAjax
(
int
uid
,
int
isAdmin
)
{
{
var
result
=
new
ResultModel
();
var
result
=
new
ResultModel
();
...
@@ -902,8 +947,9 @@ namespace backstage.Controllers
...
@@ -902,8 +947,9 @@ namespace backstage.Controllers
//加入admin list
//加入admin list
if
(
existAdmin
==
null
)
if
(
existAdmin
==
null
)
{
{
if
(
isAdmin
==
true
)
if
(
isAdmin
==
1
)
{
{
url
=
_config
[
"IP"
]
+
"/admin/add"
;
parameters
=
new
Dictionary
<
string
,
string
>
parameters
=
new
Dictionary
<
string
,
string
>
{
{
{
"token"
,
token
},
{
"token"
,
token
},
...
@@ -949,7 +995,7 @@ namespace backstage.Controllers
...
@@ -949,7 +995,7 @@ namespace backstage.Controllers
{
{
url
=
_config
[
"IP"
]
+
"/admin/mod"
;
url
=
_config
[
"IP"
]
+
"/admin/mod"
;
httpMethod
=
HttpMethod
.
Post
;
httpMethod
=
HttpMethod
.
Post
;
existAdmin
.
enabled
=
isAdmin
?
1
:
0
;
existAdmin
.
enabled
=
isAdmin
;
parameters
=
new
Dictionary
<
string
,
string
>
parameters
=
new
Dictionary
<
string
,
string
>
{
{
...
...
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