Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PersonalDB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
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
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
IQB
PersonalDB
Merge requests
!54
Release 1
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Release 1
release-1
into
develop
Overview
0
Commits
6
Pipelines
4
Changes
32
Merged
Martin Mechtel
requested to merge
release-1
into
develop
2 years ago
Overview
0
Commits
6
Pipelines
4
Changes
32
Expand
0
0
Merge request reports
Compare
develop
version 1
b6c5f119
2 years ago
develop (base)
and
latest version
latest version
225a1b35
6 commits,
2 years ago
version 1
b6c5f119
10 commits,
2 years ago
32 files
+
455
−
191
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
32
Search (e.g. *.vue) (Ctrl+P)
apps/api/src/app/auth/idm-guard.service.ts
0 → 100644
+
23
−
0
Options
import
{
CanActivate
,
ExecutionContext
,
Injectable
,
UnauthorizedException
}
from
'
@nestjs/common
'
;
import
{
AuthService
}
from
'
./service/auth.service
'
;
@
Injectable
()
export
class
IdmGuard
implements
CanActivate
{
constructor
(
private
authService
:
AuthService
)
{}
async
canActivate
(
context
:
ExecutionContext
)
{
const
req
=
context
.
switchToHttp
().
getRequest
();
const
userId
=
req
.
user
.
id
;
const
isAdmin
=
await
this
.
authService
.
isCmsAdminUser
(
userId
);
if
(
!
isAdmin
)
{
throw
new
UnauthorizedException
();
}
return
true
;
}
}
Loading