Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
worker
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chaos Parcel Service
worker
Commits
c23a45d2
Commit
c23a45d2
authored
1 year ago
by
Tim Neumann
Browse files
Options
Downloads
Patches
Plain Diff
feat(login): Store token in session storage
parent
e5a8342e
Branches
Branches containing commit
Tags
6.2.10
Tags containing commit
2 merge requests
!6
Store token
,
!5
feat(login): Store token in session storage
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dist/bundle.js
+1
-1
1 addition, 1 deletion
dist/bundle.js
src/js/main.js
+18
-0
18 additions, 0 deletions
src/js/main.js
with
19 additions
and
1 deletion
dist/bundle.js
+
1
−
1
View file @
c23a45d2
This diff is collapsed.
Click to expand it.
src/js/main.js
+
18
−
0
View file @
c23a45d2
...
@@ -37,6 +37,22 @@ async function getConfig() {
...
@@ -37,6 +37,22 @@ async function getConfig() {
}
}
export
async
function
login
()
{
export
async
function
login
()
{
let
token_from_storage
=
window
.
sessionStorage
.
getItem
(
"
access_token
"
);
if
(
token_from_storage
!==
null
)
{
let
checkResponse
=
await
fetch
(
config
.
backend_url
+
"
/token/check
"
,
{
method
:
"
GET
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
"
Authorization
"
:
"
Bearer
"
+
token_from_storage
,
},
});
if
(
checkResponse
.
ok
)
{
access_token
=
token_from_storage
;
return
;
}
}
var
password
=
prompt
(
"
provide the shared secret
"
);
var
password
=
prompt
(
"
provide the shared secret
"
);
var
form
=
new
FormData
();
var
form
=
new
FormData
();
form
.
append
(
"
grant_type
"
,
"
password
"
);
form
.
append
(
"
grant_type
"
,
"
password
"
);
...
@@ -48,6 +64,8 @@ export async function login() {
...
@@ -48,6 +64,8 @@ export async function login() {
});
});
var
result
=
await
response
.
json
();
var
result
=
await
response
.
json
();
access_token
=
result
.
access_token
;
access_token
=
result
.
access_token
;
window
.
sessionStorage
.
setItem
(
"
access_token
"
,
access_token
);
}
}
...
...
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