This repository was archived by the owner on Sep 15, 2022. It is now read-only.
forked from CPete91/Quick-Phone-Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,5 @@ typings/ | |
|
||
# next.js build output | ||
.next | ||
|
||
sandbox.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
function setAuthToken(token) { | ||
return window.localStorage.setItem('authToken', token); | ||
} | ||
|
||
function setIdToken(token) { | ||
return window.localStorage.setItem('idToken', token); | ||
} | ||
|
||
function getAuthToken() { | ||
return window.localStorage.getItem('authToken'); | ||
} | ||
|
||
function getIdToken() { | ||
return window.localStorage.getItem('idToken'); | ||
} | ||
|
||
function clearTokens() { | ||
window.localStorage.clear(); | ||
} | ||
|
||
function getLoginUrl() { | ||
return "https://synchrony.auth.us-east-2.amazoncognito.com/login?response_type=token&client_id=13d5f6opbi4o4sevg6fm3lpuml&redirect_uri=http://localhost:8000/callback&state=STATE&scope=openid+profile"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>PoC Javascript Device</title> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> | ||
<script src='../auth.js'></script> | ||
<script> | ||
//Redirect to auth if the user has not logged in. | ||
function checkAuth() { | ||
// Well this is weird, but ok... | ||
// Sure it's a configuration thing in Cognito. | ||
rawUrl = window.location.href; | ||
url = new URL(rawUrl.replace("/#", "?")); | ||
var urlParams = new URLSearchParams(url.search); | ||
|
||
if (urlParams.has('id_token') && urlParams.has('access_token')) { | ||
//TODO: Validate tokens with Cognito. | ||
setAuthToken(urlParams.get('access_token')); | ||
setIdToken(urlParams.get('id_token')); | ||
} | ||
gotoOrigin(); | ||
} | ||
|
||
function gotoOrigin() { | ||
rawUrl = window.location.href; | ||
url = new URL(rawUrl.replace("/#", "?")); | ||
window.location = url.origin; | ||
} | ||
window.addEventListener('load', checkAuth, false); | ||
</script> | ||
</head> | ||
<body> | ||
<h1>Successful Login</h1> | ||
If you're not redirected automatically please click <a href="javascript:gotoOrigin()">here</a>. | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters