Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchParapheur
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
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
Maarch
MaarchParapheur
Commits
2a6dd5fd
Verified
Commit
2a6dd5fd
authored
5 years ago
by
Alex ORLUC
Browse files
Options
Downloads
Patches
Plain Diff
FIX #11312 TIME 1:30 move authenticationInformations in guard
parent
eae97192
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/frontend/app/app.component.ts
+0
-9
0 additions, 9 deletions
src/frontend/app/app.component.ts
src/frontend/app/service/auth.guard.ts
+54
-5
54 additions, 5 deletions
src/frontend/app/service/auth.guard.ts
with
54 additions
and
14 deletions
src/frontend/app/app.component.ts
+
0
−
9
View file @
2a6dd5fd
...
@@ -30,15 +30,6 @@ export class AppComponent {
...
@@ -30,15 +30,6 @@ export class AppComponent {
private
localStorage
:
LocalStorageService
)
{
private
localStorage
:
LocalStorageService
)
{
iconReg
.
addSvgIcon
(
'
maarchLogo
'
,
sanitizer
.
bypassSecurityTrustResourceUrl
(
'
../src/frontend/assets/logo_white.svg
'
));
iconReg
.
addSvgIcon
(
'
maarchLogo
'
,
sanitizer
.
bypassSecurityTrustResourceUrl
(
'
../src/frontend/assets/logo_white.svg
'
));
this
.
http
.
get
(
'
../rest/authenticationInformations
'
)
.
subscribe
((
data
:
any
)
=>
{
this
.
authService
.
authMode
=
data
.
connection
;
this
.
authService
.
changeKey
=
data
.
changeKey
;
this
.
localStorage
.
setAppSession
(
data
.
instanceId
);
if
(
this
.
authService
.
changeKey
)
{
this
.
dialog
.
open
(
AlertComponent
,
{
autoFocus
:
false
,
disableClose
:
true
,
data
:
{
mode
:
'
warning
'
,
title
:
'
lang.warnPrivateKeyTitle
'
,
msg
:
'
lang.warnPrivateKey
'
}
});
}
});
if
(
this
.
cookieService
.
check
(
'
maarchParapheurLang
'
))
{
if
(
this
.
cookieService
.
check
(
'
maarchParapheurLang
'
))
{
const
cookieInfoLang
=
this
.
cookieService
.
get
(
'
maarchParapheurLang
'
);
const
cookieInfoLang
=
this
.
cookieService
.
get
(
'
maarchParapheurLang
'
);
translate
.
setDefaultLang
(
cookieInfoLang
);
translate
.
setDefaultLang
(
cookieInfoLang
);
...
...
This diff is collapsed.
Click to expand it.
src/frontend/app/service/auth.guard.ts
+
54
−
5
View file @
2a6dd5fd
...
@@ -6,17 +6,29 @@ import { HttpClient } from '@angular/common/http';
...
@@ -6,17 +6,29 @@ import { HttpClient } from '@angular/common/http';
import
{
SignaturesContentService
}
from
'
./signatures.service
'
;
import
{
SignaturesContentService
}
from
'
./signatures.service
'
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
AuthService
}
from
'
./auth.service
'
;
import
{
AuthService
}
from
'
./auth.service
'
;
import
{
map
}
from
'
rxjs/operators
'
;
import
{
Observable
}
from
'
rxjs
'
;
import
{
LocalStorageService
}
from
'
./local-storage.service
'
;
import
{
AlertComponent
}
from
'
../plugins/alert.component
'
;
import
{
MatDialog
}
from
'
@angular/material
'
;
@
Injectable
({
@
Injectable
({
providedIn
:
'
root
'
providedIn
:
'
root
'
})
})
export
class
AuthGuard
implements
CanActivate
{
export
class
AuthGuard
implements
CanActivate
{
constructor
(
private
translate
:
TranslateService
,
public
http
:
HttpClient
,
private
router
:
Router
,
public
signaturesService
:
SignaturesContentService
,
private
cookieService
:
CookieService
,
public
authService
:
AuthService
)
{
}
constructor
(
private
translate
:
TranslateService
,
public
http
:
HttpClient
,
private
router
:
Router
,
public
signaturesService
:
SignaturesContentService
,
private
cookieService
:
CookieService
,
public
authService
:
AuthService
,
private
localStorage
:
LocalStorageService
,
public
dialog
:
MatDialog
)
{
}
canActivate
(
route
:
ActivatedRouteSnapshot
,
state
:
RouterStateSnapshot
)
{
canActivate
(
route
:
ActivatedRouteSnapshot
,
state
:
RouterStateSnapshot
)
:
Observable
<
boolean
>
|
boolean
{
cons
t
tokenInfo
=
this
.
authService
.
getToken
();
le
t
tokenInfo
=
this
.
authService
.
getToken
();
if
(
tokenInfo
!==
null
)
{
if
(
tokenInfo
!==
null
)
{
if
(
this
.
authService
.
user
.
id
===
undefined
)
{
if
(
this
.
authService
.
user
.
id
===
undefined
)
{
this
.
authService
.
user
=
JSON
.
parse
(
atob
(
tokenInfo
.
split
(
'
.
'
)[
1
])).
user
;
this
.
authService
.
user
=
JSON
.
parse
(
atob
(
tokenInfo
.
split
(
'
.
'
)[
1
])).
user
;
...
@@ -41,8 +53,45 @@ export class AuthGuard implements CanActivate {
...
@@ -41,8 +53,45 @@ export class AuthGuard implements CanActivate {
return
true
;
return
true
;
}
else
{
}
else
{
this
.
authService
.
logout
();
return
this
.
http
.
get
(
'
../rest/authenticationInformations
'
)
return
false
;
.
pipe
(
map
((
data
:
any
)
=>
{
this
.
authService
.
authMode
=
data
.
connection
;
this
.
authService
.
changeKey
=
data
.
changeKey
;
this
.
localStorage
.
setAppSession
(
data
.
instanceId
);
tokenInfo
=
this
.
authService
.
getToken
();
if
(
tokenInfo
!==
null
)
{
this
.
authService
.
user
=
JSON
.
parse
(
atob
(
tokenInfo
.
split
(
'
.
'
)[
1
])).
user
;
this
.
translate
.
use
(
this
.
authService
.
user
.
preferences
.
lang
);
this
.
cookieService
.
set
(
'
maarchParapheurLang
'
,
this
.
authService
.
user
.
preferences
.
lang
);
if
(
this
.
signaturesService
.
signaturesList
.
length
===
0
)
{
this
.
http
.
get
(
'
../rest/users/
'
+
this
.
authService
.
user
.
id
+
'
/signatures
'
)
.
subscribe
((
dataSign
:
any
)
=>
{
this
.
signaturesService
.
signaturesList
=
dataSign
.
signatures
;
});
}
if
(
this
.
authService
.
user
.
picture
===
undefined
)
{
this
.
http
.
get
(
'
../rest/users/
'
+
this
.
authService
.
user
.
id
+
'
/picture
'
)
.
subscribe
((
dataPic
:
any
)
=>
{
this
.
authService
.
user
.
picture
=
dataPic
.
picture
;
});
}
if
(
this
.
authService
.
changeKey
)
{
this
.
dialog
.
open
(
AlertComponent
,
{
autoFocus
:
false
,
disableClose
:
true
,
data
:
{
mode
:
'
warning
'
,
title
:
'
lang.warnPrivateKeyTitle
'
,
msg
:
'
lang.warnPrivateKey
'
}
});
}
return
true
;
}
else
{
this
.
authService
.
logout
();
return
false
;
}
})
);
}
}
}
}
}
}
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