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
d4f60dfe
Commit
d4f60dfe
authored
Jan 14, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow query user with id
parent
c765c453
Pipeline
#19493
passed with stages
in 2 minutes and 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
src/controllers/user.ts
src/controllers/user.ts
+20
-11
No files found.
src/controllers/user.ts
View file @
d4f60dfe
...
...
@@ -193,10 +193,21 @@ export const UpdateAccount = async (ctx: Context) => {
ctx
.
body
=
(
await
userRep
.
save
(
user
)).
cleanSensitiveData
();
};
async
function
queryUser
(
username
:
string
)
{
if
(
!
username
)
return
;
const
userRepository
=
getEntityManager
().
getRepository
(
User
);
const
possibleId
=
parseInt
(
username
);
const
query
=
userRepository
.
createQueryBuilder
(
'
user
'
)
.
where
(
'
user.username = :username
'
,
{
username
})
if
(
!
isNaN
(
possibleId
))
{
query
.
orWhere
(
'
user.id = :id
'
,
{
id
:
possibleId
});
}
return
query
.
getOne
();
}
export
const
legacyYGOProAuth
=
async
(
ctx
:
Context
)
=>
{
const
userRepository
=
getEntityManager
().
getRepository
(
User
);
const
user
=
await
userRepository
.
findOne
({
username
:
ctx
.
params
.
username
});
const
user
=
await
queryUser
(
ctx
.
params
.
username
);
if
(
!
user
)
{
return
ctx
.
throw
(
404
);
}
...
...
@@ -205,8 +216,11 @@ export const legacyYGOProAuth = async (ctx: Context) => {
};
export
const
legacyYGOProAvatar
=
async
(
ctx
:
Context
)
=>
{
const
userRepository
=
getEntityManager
().
getRepository
(
User
);
const
user
=
await
userRepository
.
findOne
({
username
:
ctx
.
params
.
username
});
// block request from pro2
if
((
ctx
.
header
[
'
user-agent
'
]
as
string
)?.
startsWith
(
'
UnityPlayer
'
))
{
return
ctx
.
throw
(
404
);
}
const
user
=
await
queryUser
(
ctx
.
params
.
username
);
if
(
!
user
)
{
return
ctx
.
throw
(
404
);
}
...
...
@@ -214,17 +228,12 @@ export const legacyYGOProAvatar = async (ctx: Context) => {
if
(
avatarUrl
)
{
ctx
.
redirect
(
avatarUrl
);
}
// block request from pro2
if
((
ctx
.
header
[
'
user-agent
'
]
as
string
)?.
startsWith
(
'
UnityPlayer
'
))
{
ctx
.
throw
(
404
);
}
ctx
.
redirect
(
'
https://cdn02.moecube.com:444/accounts/default_avatar.jpg
'
);
};
export
const
getUserAvatar
=
async
(
ctx
:
Context
)
=>
{
const
userRepository
=
getEntityManager
().
getRepository
(
User
);
const
user
=
await
userRepository
.
findOne
({
username
:
ctx
.
params
.
username
});
if
(
!
user
)
{
const
user
=
await
queryUser
(
ctx
.
params
.
username
);
if
(
!
user
)
{
return
ctx
.
throw
(
404
);
}
ctx
.
body
=
user
.
avatarURL
()
...
...
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