Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoCLI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
UI
DojoCLI
Commits
82331276
Commit
82331276
authored
1 year ago
by
kelly.nguyen
Browse files
Options
Downloads
Patches
Plain Diff
add check privileges to user list
parent
fab67593
No related branches found
No related tags found
No related merge requests found
Pipeline
#29946
failed
1 year ago
Stage: code_quality
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
NodeApp/src/commander/user/subcommands/UserChangeRoleCommand.ts
+11
-7
11 additions, 7 deletions
...p/src/commander/user/subcommands/UserChangeRoleCommand.ts
NodeApp/src/commander/user/subcommands/UserListCommand.ts
+16
-1
16 additions, 1 deletion
NodeApp/src/commander/user/subcommands/UserListCommand.ts
with
27 additions
and
8 deletions
NodeApp/src/commander/user/subcommands/UserChangeRoleCommand.ts
+
11
−
7
View file @
82331276
...
...
@@ -15,16 +15,12 @@ class UserChangeRoleCommand extends CommanderCommand {
}
protected
async
commandAction
(
id
:
string
,
newRole
:
string
):
Promise
<
void
>
{
// TODO : newRole -> type UserRole
// check privileges
{
console
.
log
(
chalk
.
cyan
(
'
Please wait while we are changing the role of the user...
'
));
const
spinner
=
ora
({
text
:
'
Retrieving gitlab tokens
'
,
indent
:
4
}).
start
();
// TODO : newRole -> type UserRole
// TODO : Can't modify own role
// check if ADMIN
const
sessionResult
=
await
SessionManager
.
testSession
(
true
,
[
'
admin
'
]);
console
.
log
(
sessionResult
);
console
.
log
(
SessionManager
.
profile
?.
id
);
...
...
@@ -32,6 +28,14 @@ class UserChangeRoleCommand extends CommanderCommand {
if
(
!
sessionResult
||
!
sessionResult
.
admin
)
{
return
;
}
}
// change role
{
const
spinner
=
ora
({
text
:
'
Updating role
'
,
indent
:
4
}).
start
();
try
{
if
(
SessionManager
.
profile
?.
id
!=
+
id
)
{
...
...
This diff is collapsed.
Click to expand it.
NodeApp/src/commander/user/subcommands/UserListCommand.ts
+
16
−
1
View file @
82331276
...
...
@@ -3,6 +3,7 @@ import CommanderCommand from "../../CommanderCommand";
import
DojoBackendManager
from
"
../../../managers/DojoBackendManager
"
;
import
User
from
"
../../../sharedByClients/models/User
"
;
import
ora
from
"
ora
"
;
import
SessionManager
from
"
../../../managers/SessionManager
"
;
class
UserListCommand
extends
CommanderCommand
{
protected
commandName
:
string
=
'
list
'
;
...
...
@@ -16,9 +17,23 @@ class UserListCommand extends CommanderCommand {
protected
async
commandAction
():
Promise
<
void
>
{
let
users
:
User
[]
=
[];
//
Retrieve data
//
check privileges
{
console
.
log
(
chalk
.
cyan
(
'
Please wait while we are retrieving the users...
'
));
// check if ADMIN
const
sessionResult
=
await
SessionManager
.
testSession
(
true
,
[
'
admin
'
]);
console
.
log
(
sessionResult
);
console
.
log
(
SessionManager
.
profile
?.
id
);
if
(
!
sessionResult
||
!
sessionResult
.
admin
)
{
return
;
}
}
// Retrieve data
{
// TODO : display data in table
users
=
await
DojoBackendManager
.
getAllUsers
();
users
.
forEach
(
user
=>
{
const
oraInfo
=
(
message
:
string
)
=>
{
...
...
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