Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
826a2466
Commit
826a2466
authored
6 years ago
by
MeiMei
Committed by
syuilo
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
管理者がサインイン履歴を参照できるツール (#3870)
* 管理者がサインイン履歴を参照できるツール * remove debug code
parent
273bc650
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tools/show-signin-history.ts
+57
-0
57 additions, 0 deletions
src/tools/show-signin-history.ts
with
57 additions
and
0 deletions
src/tools/show-signin-history.ts
0 → 100644
+
57
−
0
View file @
826a2466
// node built/tools/show-signin-history username
// => {Success} {Date} {IPAddrsss}
// node built/tools/show-signin-history username user-agent,x-forwarded-for
// with user-agent and x-forwarded-for
// node built/tools/show-signin-history username all
// with full request headers
import
User
from
'
../models/user
'
;
import
Signin
from
'
../models/signin
'
;
async
function
main
(
username
:
string
,
headers
:
string
[])
{
const
user
=
await
User
.
findOne
({
host
:
null
,
usernameLower
:
username
.
toLowerCase
(),
});
if
(
user
===
null
)
throw
'
User not found
'
;
const
history
=
await
Signin
.
find
({
userId
:
user
.
_id
});
for
(
const
signin
of
history
)
{
console
.
log
(
`
${
signin
.
success
?
'
OK
'
:
'
NG
'
}
${
signin
.
createdAt
?
signin
.
createdAt
.
toISOString
()
:
'
Unknown
'
}
${
signin
.
ip
}
`
);
// headers
if
(
headers
!=
null
)
{
for
(
const
key
of
Object
.
keys
(
signin
.
headers
))
{
if
(
headers
.
includes
(
'
all
'
)
||
headers
.
includes
(
key
))
{
console
.
log
(
`
${
key
}
:
${
signin
.
headers
[
key
]}
`
);
}
}
}
}
}
// get args
const
args
=
process
.
argv
.
slice
(
2
);
let
username
=
args
[
0
];
let
headers
:
string
[];
if
(
args
[
1
]
!=
null
)
{
headers
=
args
[
1
].
split
(
/,/
).
map
(
header
=>
header
.
toLowerCase
());
}
// normalize args
username
=
username
.
replace
(
/^@/
,
''
);
main
(
username
,
headers
).
then
(()
=>
{
process
.
exit
(
0
);
}).
catch
(
e
=>
{
console
.
warn
(
e
);
process
.
exit
(
1
);
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment