generated from Arquisoft/radarin_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from Arquisoft/qr_auth
Qr auth
- Loading branch information
Showing
6 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,58 @@ | ||
import keypair from 'keypair'; | ||
import QRCode from 'react-qr-code'; | ||
import React, { useState } from 'react'; | ||
import { useSession } from "@inrupt/solid-ui-react"; | ||
import { | ||
getSolidDataset, | ||
getThing, | ||
setStringNoLocale, | ||
setThing, | ||
saveSolidDatasetAt, | ||
} from "@inrupt/solid-client"; | ||
import { fetch } from "@inrupt/solid-client-authn-browser"; | ||
import { VCARD } from "@inrupt/vocab-common-rdf"; | ||
import { Button } from "@material-ui/core"; | ||
import "../css/QRPage.css"; | ||
|
||
export default function QRPage() { | ||
const { session } = useSession(); | ||
const { webId } = session.info; | ||
const [showQR, setShowQR] = useState(false); | ||
|
||
|
||
const [pair, setPair] = useState(() => { | ||
const pair = keypair({ bits: 1024 }); | ||
return pair; | ||
}); | ||
|
||
const privateKey = pair.private; | ||
const publicKey = pair.public; | ||
|
||
|
||
|
||
function logKey() { | ||
getSolidDataset(webId.split("#")[0], { fetch: fetch }).then((response) => { | ||
const profile = getThing(response, webId); | ||
let updatedProfile = setStringNoLocale(profile, VCARD.key, publicKey); | ||
console.log(publicKey); | ||
const myChangedDataset = setThing(response, updatedProfile); | ||
saveSolidDatasetAt(webId.split("#")[0], myChangedDataset, { fetch: fetch }).then(() => { | ||
setShowQR(true); | ||
}); | ||
}); | ||
} | ||
|
||
|
||
if(showQR) { | ||
return (<div className="centerMe"><QRCode | ||
level="Q" | ||
size={512} | ||
value={JSON.stringify({ | ||
webId, | ||
privateKey | ||
})} | ||
/></div>); | ||
} | ||
|
||
return (<div className="centerMe"><Button color="primary" variant="contained" onClick={logKey}>Press me</Button></div>); | ||
} |
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,7 @@ | ||
.centerMe { | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
padding: 2em; | ||
} |