Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Moecube Accounts Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Moecube Accounts Backend
Commits
90a80e72
Commit
90a80e72
authored
Sep 26, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sensitive data modify
parent
5799ae7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
src/controllers/user.ts
src/controllers/user.ts
+16
-2
src/routes.ts
src/routes.ts
+3
-1
No files found.
src/controllers/user.ts
View file @
90a80e72
...
...
@@ -56,10 +56,16 @@ export const UpdateProfiles = async (ctx: Context) => {
ctx
.
throw
(
400
);
}
if
(
user
.
username
&&
process
.
env
.
NO_CHANGE_USERNAME
)
{
const
targetUser
=
ctx
.
request
.
body
;
if
(
targetUser
.
username
&&
process
.
env
.
NO_CHANGE_USERNAME
)
{
ctx
.
throw
(
"
Changing username is currently not allowed.
"
,
400
);
}
if
(
user
.
id
!=
targetUser
.
id
||
targetUser
.
admin
!=
null
||
targetUser
.
active
!=
null
||
targetUser
.
registration_ip_address
||
targetUser
.
ip_address
)
{
ctx
.
throw
(
"
Cannot change sensitive data.
"
,
400
);
}
const
userRep
=
getEntityManager
().
getRepository
(
User
);
let
_user
:
User
|
undefined
=
await
userRep
...
...
@@ -73,7 +79,7 @@ export const UpdateProfiles = async (ctx: Context) => {
}
Object
.
assign
(
_user
,
ctx
.
request
.
body
);
Object
.
assign
(
_user
,
targetUser
);
await
getEntityManager
().
save
(
_user
);
...
...
@@ -215,3 +221,11 @@ export const getUserAvatar = async (ctx: Context) => {
}
ctx
.
body
=
user
.
avatarURL
()
};
export
const
allowChangeUsername
=
async
(
ctx
:
Context
)
=>
{
ctx
.
status
=
200
;
const
envData
=
process
.
env
.
NO_CHANGE_USERNAME
;
ctx
.
body
=
{
allow
:
!
envData
,
reason
:
envData
}
};
src/routes.ts
View file @
90a80e72
...
...
@@ -23,5 +23,7 @@ router.get('/users/:username.json', user.legacyYGOProAuth);
router
.
get
(
'
/users/:username.png
'
,
user
.
legacyYGOProAvatar
);
router
.
get
(
'
/users/:username.avatar
'
,
user
.
getUserAvatar
);
router
.
get
(
'
/allowChangeUsername
'
,
user
.
allowChangeUsername
)
export
default
router
;
\ No newline at end of file
export
default
router
;
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