Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Albin Geraud Kouatcho Nkuigwa
PSE_Projekt
Commits
043820a6
Commit
043820a6
authored
Jun 17, 2018
by
Janik Münzenberger
Browse files
Fixed session timeout
parent
1f101f0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/app/services/api.service.ts
View file @
043820a6
...
...
@@ -6,6 +6,7 @@ import { catchError } from 'rxjs/operators';
import
{
environment
}
from
'
../../environments/environment
'
;
import
{
AuthService
}
from
'
./auth.service
'
;
import
{
Router
}
from
'
@angular/router
'
;
@
Injectable
()
...
...
@@ -13,7 +14,7 @@ export class ApiService {
public
static
API_URL
:
string
=
environment
.
API_HOST
+
"
/api/
"
;
constructor
(
private
httpClient
:
HttpClient
,
private
authService
:
AuthService
)
{
}
constructor
(
private
httpClient
:
HttpClient
,
private
authService
:
AuthService
,
private
router
:
Router
)
{
}
get
(
serviceUrl
:
string
):
Observable
<
any
>
{
return
this
.
httpClient
.
get
(
ApiService
.
API_URL
+
serviceUrl
,
{
headers
:
this
.
authService
.
authHeader
()})
...
...
@@ -43,9 +44,10 @@ export class ApiService {
);
}
private
handleUnauthorizedError
(
err
){
private
handleUnauthorizedError
=
(
err
)
=>
{
if
(
err
.
status
===
401
){
this
.
authService
.
logout
();
this
.
router
.
navigate
([
"
/login
"
],
{
queryParams
:
{
logout
:
true
,
reason
:
"
timeout
"
}});
return
empty
();
}
return
throwError
(
err
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment