Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dspace7 Angular
Manage
Activity
Members
Labels
Plan
Issues
42
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
vtechworks
Dspace7 Angular
Commits
abb8fc16
Commit
abb8fc16
authored
7 years ago
by
Giuseppe Digilio
Browse files
Options
Downloads
Patches
Plain Diff
Added comment
parent
564f148e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/core/auth/auth-request.service.ts
+1
-6
1 addition, 6 deletions
src/app/core/auth/auth-request.service.ts
src/app/core/auth/auth.service.ts
+8
-6
8 additions, 6 deletions
src/app/core/auth/auth.service.ts
src/app/core/data/request.service.ts
+1
-0
1 addition, 0 deletions
src/app/core/data/request.service.ts
with
10 additions
and
12 deletions
src/app/core/auth/auth-request.service.ts
+
1
−
6
View file @
abb8fc16
...
@@ -16,12 +16,6 @@ export class AuthRequestService extends HALEndpointService {
...
@@ -16,12 +16,6 @@ export class AuthRequestService extends HALEndpointService {
protected
linkName
=
'
authn
'
;
protected
linkName
=
'
authn
'
;
protected
browseEndpoint
=
''
;
protected
browseEndpoint
=
''
;
/**
* True if authenticated
* @type
*/
private
_authenticated
=
false
;
constructor
(
protected
responseCache
:
ResponseCacheService
,
constructor
(
protected
responseCache
:
ResponseCacheService
,
protected
requestService
:
RequestService
,
protected
requestService
:
RequestService
,
@
Inject
(
GLOBAL_CONFIG
)
protected
EnvConfig
:
GlobalConfig
)
{
@
Inject
(
GLOBAL_CONFIG
)
protected
EnvConfig
:
GlobalConfig
)
{
...
@@ -31,6 +25,7 @@ export class AuthRequestService extends HALEndpointService {
...
@@ -31,6 +25,7 @@ export class AuthRequestService extends HALEndpointService {
protected
fetchRequest
(
request
:
RestRequest
):
Observable
<
any
>
{
protected
fetchRequest
(
request
:
RestRequest
):
Observable
<
any
>
{
const
[
successResponse
,
errorResponse
]
=
this
.
responseCache
.
get
(
request
.
href
)
const
[
successResponse
,
errorResponse
]
=
this
.
responseCache
.
get
(
request
.
href
)
.
map
((
entry
:
ResponseCacheEntry
)
=>
entry
.
response
)
.
map
((
entry
:
ResponseCacheEntry
)
=>
entry
.
response
)
// TODO to review when https://github.com/DSpace/dspace-angular/issues/217 will be fixed
.
do
(()
=>
this
.
responseCache
.
remove
(
request
.
href
))
.
do
(()
=>
this
.
responseCache
.
remove
(
request
.
href
))
.
partition
((
response
:
RestResponse
)
=>
response
.
isSuccessful
);
.
partition
((
response
:
RestResponse
)
=>
response
.
isSuccessful
);
return
Observable
.
merge
(
return
Observable
.
merge
(
...
...
This diff is collapsed.
Click to expand it.
src/app/core/auth/auth.service.ts
+
8
−
6
View file @
abb8fc16
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Observable
}
from
'
rxjs/Observable
'
;
import
{
Observable
}
from
'
rxjs/Observable
'
;
import
{
filter
,
map
,
withLatestFrom
}
from
'
rxjs/operators
'
;
import
{
map
,
withLatestFrom
}
from
'
rxjs/operators
'
;
import
{
Eperson
}
from
'
../eperson/models/eperson.model
'
;
import
{
Eperson
}
from
'
../eperson/models/eperson.model
'
;
import
{
AuthRequestService
}
from
'
./auth-request.service
'
;
import
{
AuthRequestService
}
from
'
./auth-request.service
'
;
...
@@ -20,6 +20,7 @@ import { Router } from '@angular/router';
...
@@ -20,6 +20,7 @@ import { Router } from '@angular/router';
import
{
CookieAttributes
}
from
'
js-cookie
'
;
import
{
CookieAttributes
}
from
'
js-cookie
'
;
export
const
LOGIN_ROUTE
=
'
/login
'
;
export
const
LOGIN_ROUTE
=
'
/login
'
;
/**
/**
* The auth service.
* The auth service.
*/
*/
...
@@ -43,7 +44,7 @@ export class AuthService {
...
@@ -43,7 +44,7 @@ export class AuthService {
// If current route is different from the one setted in authentication guard
// If current route is different from the one setted in authentication guard
// and is not the login route, clear redirect url and messages
// and is not the login route, clear redirect url and messages
const
routeUrlObs
=
this
.
store
.
select
(
routerStateSelector
)
const
routeUrlObs
=
this
.
store
.
select
(
routerStateSelector
)
.
filter
((
routerState
:
RouterReducerState
)
=>
isNotUndefined
(
routerState
)
&&
isNotUndefined
(
routerState
.
state
)
)
.
filter
((
routerState
:
RouterReducerState
)
=>
isNotUndefined
(
routerState
)
&&
isNotUndefined
(
routerState
.
state
))
.
filter
((
routerState
:
RouterReducerState
)
=>
(
routerState
.
state
.
url
!==
LOGIN_ROUTE
))
.
filter
((
routerState
:
RouterReducerState
)
=>
(
routerState
.
state
.
url
!==
LOGIN_ROUTE
))
.
map
((
routerState
:
RouterReducerState
)
=>
routerState
.
state
.
url
);
.
map
((
routerState
:
RouterReducerState
)
=>
routerState
.
state
.
url
);
const
redirectUrlObs
=
this
.
getRedirectUrl
();
const
redirectUrlObs
=
this
.
getRedirectUrl
();
...
@@ -52,8 +53,8 @@ export class AuthService {
...
@@ -52,8 +53,8 @@ export class AuthService {
map
(([
routeUrl
,
redirectUrl
])
=>
[
routeUrl
,
redirectUrl
])
map
(([
routeUrl
,
redirectUrl
])
=>
[
routeUrl
,
redirectUrl
])
).
filter
(([
routeUrl
,
redirectUrl
])
=>
isNotEmpty
(
redirectUrl
)
&&
(
routeUrl
!==
redirectUrl
))
).
filter
(([
routeUrl
,
redirectUrl
])
=>
isNotEmpty
(
redirectUrl
)
&&
(
routeUrl
!==
redirectUrl
))
.
subscribe
(()
=>
{
.
subscribe
(()
=>
{
this
.
setRedirectUrl
(
''
);
this
.
setRedirectUrl
(
''
);
});
});
}
}
/**
/**
...
@@ -202,7 +203,7 @@ export class AuthService {
...
@@ -202,7 +203,7 @@ export class AuthService {
}
}
/**
/**
* Check if a token is
abou
t to expire
* Check if a token is
nex
t to
be
expire
d
* @returns {boolean}
* @returns {boolean}
*/
*/
public
isTokenExpiring
():
Observable
<
boolean
>
{
public
isTokenExpiring
():
Observable
<
boolean
>
{
...
@@ -226,6 +227,7 @@ export class AuthService {
...
@@ -226,6 +227,7 @@ export class AuthService {
const
token
=
this
.
getToken
();
const
token
=
this
.
getToken
();
return
token
&&
token
.
expires
<
Date
.
now
();
return
token
&&
token
.
expires
<
Date
.
now
();
}
}
/**
/**
* Save authentication token info
* Save authentication token info
*
*
...
@@ -234,7 +236,7 @@ export class AuthService {
...
@@ -234,7 +236,7 @@ export class AuthService {
*/
*/
public
storeToken
(
token
:
AuthTokenInfo
)
{
public
storeToken
(
token
:
AuthTokenInfo
)
{
const
expires
=
new
Date
(
token
.
expires
);
const
expires
=
new
Date
(
token
.
expires
);
const
options
:
CookieAttributes
=
{
expires
:
expires
};
const
options
:
CookieAttributes
=
{
expires
:
expires
};
return
this
.
storage
.
set
(
TOKENITEM
,
token
,
options
);
return
this
.
storage
.
set
(
TOKENITEM
,
token
,
options
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/app/core/data/request.service.ts
+
1
−
0
View file @
abb8fc16
...
@@ -67,6 +67,7 @@ export class RequestService {
...
@@ -67,6 +67,7 @@ export class RequestService {
.
flatMap
((
uuid
:
string
)
=>
this
.
getByUUID
(
uuid
));
.
flatMap
((
uuid
:
string
)
=>
this
.
getByUUID
(
uuid
));
}
}
// TODO to review "overrideRequest" param when https://github.com/DSpace/dspace-angular/issues/217 will be fixed
configure
<
T
extends
CacheableObject
>
(
request
:
RestRequest
,
overrideRequest
:
boolean
=
false
):
void
{
configure
<
T
extends
CacheableObject
>
(
request
:
RestRequest
,
overrideRequest
:
boolean
=
false
):
void
{
if
(
request
.
method
!==
RestRequestMethod
.
Get
||
!
this
.
isCachedOrPending
(
request
)
||
overrideRequest
)
{
if
(
request
.
method
!==
RestRequestMethod
.
Get
||
!
this
.
isCachedOrPending
(
request
)
||
overrideRequest
)
{
this
.
dispatchRequest
(
request
,
overrideRequest
);
this
.
dispatchRequest
(
request
,
overrideRequest
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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