Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nshmp-apps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
ghsc
National Seismic Hazard Model Project
nshmp-apps
Commits
c0d58c10
Commit
c0d58c10
authored
4 months ago
by
Clayton, Brandon Scott
Browse files
Options
Downloads
Patches
Plain Diff
add authorizer service.
parent
5b01aac7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!538
Internal Applications
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
projects/nshmp-apps/src/app/internal/shared/services/auth.service.ts
+49
-0
49 additions, 0 deletions
...hmp-apps/src/app/internal/shared/services/auth.service.ts
with
49 additions
and
0 deletions
projects/nshmp-apps/src/app/internal/shared/services/auth.service.ts
0 → 100644
+
49
−
0
View file @
c0d58c10
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
NshmpService
,
SpinnerService
}
from
'
@ghsc/nshmp-lib-ng/nshmp
'
;
import
{
environment
}
from
'
projects/nshmp-apps/src/environments/environment
'
;
import
{
catchError
,
map
}
from
'
rxjs
'
;
interface
AuthResponse
{
isAuthorized
:
boolean
;
}
/**
* Authorizer for USGS network.
*/
@
Injectable
({
providedIn
:
'
root
'
,
})
export
class
AuthService
{
private
service
=
environment
.
webServices
.
aws
;
private
url
=
`
${
this
.
service
.
url
}${
this
.
service
.
services
.
auth
}
`
;
constructor
(
private
http
:
HttpClient
,
private
spinnerService
:
SpinnerService
,
private
nshmpService
:
NshmpService
)
{}
isAuthorized
()
{
const
ref
=
this
.
spinnerService
.
show
(
'
Checking USGS network ...
'
);
return
this
.
http
.
get
<
AuthResponse
>
(
this
.
url
).
pipe
(
map
(
response
=>
{
console
.
log
(
response
);
ref
.
close
();
if
(
!
response
.
isAuthorized
)
{
this
.
nshmpService
.
throwError
$
(
new
Error
(
'
Must be on USGS network to access internal applications
'
)
);
}
return
response
.
isAuthorized
;
}),
catchError
((
error
:
Error
)
=>
{
ref
.
close
();
return
this
.
nshmpService
.
throwError
$
(
error
);
})
);
}
}
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