Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dspace7 Angular
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
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
vtechworks
Dspace7 Angular
Commits
34e3e4bd
Commit
34e3e4bd
authored
7 years ago
by
Giuseppe Digilio
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issue when reload protected page with expired token
parent
04be7170
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/core/auth/auth.service.ts
+14
-9
14 additions, 9 deletions
src/app/core/auth/auth.service.ts
with
14 additions
and
9 deletions
src/app/core/auth/auth.service.ts
+
14
−
9
View file @
34e3e4bd
...
...
@@ -134,8 +134,17 @@ export class AuthService {
* Checks if token is present into storage and is not expired
*/
public
checkAuthenticationToken
():
Observable
<
AuthTokenInfo
>
{
const
token
=
this
.
getToken
();
return
isNotEmpty
(
token
)
&&
!
this
.
isTokenExpired
()
?
Observable
.
of
(
token
)
:
Observable
.
throw
(
false
);
return
this
.
store
.
select
(
getAuthenticationToken
)
.
map
((
authTokenInfo
:
AuthTokenInfo
)
=>
{
let
token
:
AuthTokenInfo
;
// Retrieve authentication token info and check if is valid
token
=
isNotEmpty
(
authTokenInfo
)
?
authTokenInfo
:
this
.
storage
.
get
(
TOKENITEM
);
if
(
isNotEmpty
(
token
)
&&
token
.
hasOwnProperty
(
'
accessToken
'
)
&&
isNotEmpty
(
token
.
accessToken
)
&&
!
this
.
isTokenExpired
(
token
))
{
return
token
;
}
else
{
throw
false
;
}
});
}
/**
...
...
@@ -216,10 +225,7 @@ export class AuthService {
this
.
store
.
select
(
getAuthenticationToken
)
.
subscribe
((
authTokenInfo
:
AuthTokenInfo
)
=>
{
// Retrieve authentication token info and check if is valid
token
=
isNotEmpty
(
authTokenInfo
)
?
authTokenInfo
:
this
.
storage
.
get
(
TOKENITEM
);
if
(
isEmpty
(
token
)
||
!
token
.
hasOwnProperty
(
'
accessToken
'
)
||
isEmpty
(
token
.
accessToken
))
{
token
=
null
;
}
token
=
authTokenInfo
||
null
;
});
return
token
;
}
...
...
@@ -245,8 +251,8 @@ export class AuthService {
* Check if a token is expired
* @returns {boolean}
*/
public
isTokenExpired
():
boolean
{
const
token
=
this
.
getToken
();
public
isTokenExpired
(
token
?:
AuthTokenInfo
):
boolean
{
token
=
token
||
this
.
getToken
();
return
token
&&
token
.
expires
<
Date
.
now
();
}
...
...
@@ -312,7 +318,6 @@ export class AuthService {
.
subscribe
((
redirectUrl
)
=>
{
if
(
isNotEmpty
(
redirectUrl
))
{
if
(
this
.
platform
.
isBrowser
)
{
console
.
log
(
'
CLEAR REDIRECT!!!!
'
)
this
.
clearRedirectUrl
();
}
...
...
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