Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
testcenter-frontend
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository 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
discontinued
testcenter-frontend
Commits
fa629336
Commit
fa629336
authored
4 years ago
by
mechtelm
Browse files
Options
Downloads
Patches
Plain Diff
new CodeInputComponentActivateGuard to avoid entering without valid token #131
parent
b4128529
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/app-routing-guards.ts
+16
-0
16 additions, 0 deletions
src/app/app-routing-guards.ts
src/app/app-routing.module.ts
+7
-3
7 additions, 3 deletions
src/app/app-routing.module.ts
with
23 additions
and
3 deletions
src/app/app-routing-guards.ts
+
16
−
0
View file @
fa629336
...
...
@@ -70,3 +70,19 @@ export class DirectLoginActivateGuard implements CanActivate {
}
}
@
Injectable
({
providedIn
:
'
root
'
})
export
class
CodeInputComponentActivateGuard
implements
CanActivate
{
canActivate
(
next
:
ActivatedRouteSnapshot
,
state
:
RouterStateSnapshot
):
Observable
<
boolean
>
|
Promise
<
boolean
>
|
boolean
{
const
authData
=
MainDataService
.
getAuthData
();
if
(
authData
)
{
return
authData
.
flags
.
indexOf
(
AuthFlagType
.
CODE_REQUIRED
)
>=
0
}
else
{
return
false
}
}
}
This diff is collapsed.
Click to expand it.
src/app/app-routing.module.ts
+
7
−
3
View file @
fa629336
...
...
@@ -5,7 +5,11 @@ import {LoginComponent} from "./app-root/login/login.component";
import
{
SysCheckStarterComponent
}
from
"
./app-root/sys-check-starter/sys-check-starter.component
"
;
import
{
AdminStarterComponent
}
from
"
./app-root/admin-starter/admin-starter.component
"
;
import
{
CodeInputComponent
}
from
"
./app-root/code-input/code-input.component
"
;
import
{
DirectLoginActivateGuard
,
RouteDispatcherActivateGuard
}
from
"
./app-routing-guards
"
;
import
{
CodeInputComponentActivateGuard
,
DirectLoginActivateGuard
,
RouteDispatcherActivateGuard
}
from
"
./app-routing-guards
"
;
import
{
TestStarterComponent
}
from
"
./app-root/test-starter/test-starter.component
"
;
import
{
RouteDispatcherComponent
}
from
"
./app-root/route-dispatcher/route-dispatcher.component
"
;
import
{
PrivacyComponent
}
from
"
./app-root/privacy/privacy.component
"
;
...
...
@@ -26,7 +30,7 @@ const routes: Routes = [
{
path
:
'
test-starter
'
,
component
:
TestStarterComponent
},
{
path
:
'
admin-starter
'
,
component
:
AdminStarterComponent
},
{
path
:
'
route-dispatcher
'
,
component
:
RouteDispatcherComponent
,
canActivate
:
[
RouteDispatcherActivateGuard
]},
{
path
:
'
code-input
'
,
component
:
CodeInputComponent
}
{
path
:
'
code-input
'
,
component
:
CodeInputComponent
,
canActivate
:
[
CodeInputComponentActivateGuard
]
}
]
},
{
path
:
'
priv
'
,
component
:
PrivacyComponent
},
...
...
@@ -42,6 +46,6 @@ const routes: Routes = [
@
NgModule
({
imports
:
[
RouterModule
.
forRoot
(
routes
)],
exports
:
[
RouterModule
],
providers
:
[
RouteDispatcherActivateGuard
,
DirectLoginActivateGuard
]
providers
:
[
RouteDispatcherActivateGuard
,
DirectLoginActivateGuard
,
CodeInputComponentActivateGuard
]
})
export
class
AppRoutingModule
{
}
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