-
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
1 parent
41d516d
commit 8df3224
Showing
5 changed files
with
100 additions
and
26 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
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
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 |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
<script src="https://unpkg.com/[email protected]/dist/index.js" integrity="sha384-5bXRcW9kyxxnSMbOoHzraqa7Z0PQWIao+cgeg327zit1hz5LZCEbIMx/LWKPReuB" crossorigin="anonymous"></script> | ||
<title>Let Me In</title> | ||
<link rel="stylesheet" href="main.css"> | ||
<script src="vendor/qr_packed.js"> </script> | ||
|
||
</head> | ||
<body> | ||
<header> | ||
|
@@ -15,40 +17,40 @@ <h1>Let Me In</h1> | |
|
||
<h2>Authenticate to Gain Access</h2> | ||
<div> | ||
<label for="address">Client Address</label> | ||
<input type="text" id="address"> | ||
|
||
<div> | ||
<label for="address">Scan client Address:</label> | ||
<div id="container" height="280" width="340" > | ||
|
||
<canvas hidden="" id="qr-canvas"></canvas> | ||
|
||
</div> | ||
|
||
|
||
</div> | ||
<!-- <input type="text" id="address">--> | ||
</div> | ||
|
||
<div> | ||
<!-- <div> | ||
<button type="button" id="submitVerification">Verify</button> | ||
</div> | ||
</div>--> | ||
|
||
<div> | ||
<img style="display: none" id="photo"> | ||
<h6>User photo:</h6> | ||
<img style="width:200px; length: 300px;" id="photo"> | ||
</div> | ||
|
||
<script src="vendor/@truffle/contract/dist/truffle-contract.min.js"></script> | ||
<script src="vendor/web3/dist/web3.min.js"></script> | ||
<script src="IpfsModule.js"></script> | ||
<script src="Auth.js"></script> | ||
<script src="app.js"></script> | ||
<script src="qrCodeScannerAuth.js"></script> | ||
|
||
<script> | ||
(function () { | ||
const app = new App(); | ||
const verification = document.getElementById("submitVerification"); | ||
if (verification) { | ||
verification.addEventListener("click", async () => { | ||
const auth = await app.authorization(); | ||
|
||
if (Auth.checkPermissions(auth)) { | ||
const photo = document.getElementById("photo"); | ||
photo.src = Auth.getClientURLPhoto(auth); | ||
photo.display = "block"; | ||
} else { | ||
window.alert("User not Authorized"); | ||
} | ||
}); | ||
} | ||
|
||
})(); | ||
</script> | ||
</body> | ||
|
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
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,72 @@ | ||
var qrcode = window.qrcode; | ||
|
||
const video = document.createElement("video"); | ||
const canvasElement = document.getElementById("qr-canvas"); | ||
const canvas = canvasElement.getContext("2d"); | ||
|
||
|
||
let scanning = false; | ||
const app = new App(); | ||
qrcode.callback = ((res) => { | ||
if (res) { | ||
res = res.split('ethereum:')[1]; | ||
console.log(res); | ||
//scanning = false; | ||
console.log("asdsad"); | ||
|
||
(async function(){ | ||
const auth = await app.authorization(res); | ||
console.log("asd"); | ||
if (Auth.checkPermissions(auth)) { | ||
const photoElement = document.getElementById("photo"); | ||
console.log("auth:",auth); | ||
photoElement.src = Auth.getClientURLPhoto(auth); | ||
console.log("Auth.getClientURLPhoto(auth)", Auth.getClientURLPhoto(auth)); | ||
photoElement.display = "block"; | ||
} else { | ||
window.alert("User not Authorized"); | ||
} | ||
video.srcObject.getTracks().forEach(track => { | ||
track.stop(); | ||
}); | ||
load(); | ||
//canvasElement.hidden = true; | ||
})(); | ||
|
||
|
||
} | ||
}); | ||
function load(){ | ||
navigator.mediaDevices | ||
.getUserMedia({ video: { facingMode: "environment" } }) | ||
.then(function(stream) { | ||
scanning = true; | ||
|
||
canvasElement.hidden = false; | ||
video.setAttribute("playsinline", true); // required to tell iOS safari we don't want fullscreen | ||
video.srcObject = stream; | ||
video.play(); | ||
tick(); | ||
scan(); | ||
}); | ||
} | ||
|
||
document.body.onload = () => { | ||
load(); | ||
}; | ||
|
||
function tick() { | ||
canvasElement.height = video.videoHeight; | ||
canvasElement.width = video.videoWidth; | ||
canvas.drawImage(video, 0, 0, canvasElement.width, canvasElement.height); | ||
|
||
scanning && requestAnimationFrame(tick); | ||
} | ||
|
||
function scan() { | ||
try { | ||
qrcode.decode(); | ||
} catch (e) { | ||
setTimeout(scan, 300); | ||
} | ||
} |