Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created January 12, 2022 09:29
Show Gist options
  • Save velotiotech/d6d10ae198fd976f4050cc82d36662cb to your computer and use it in GitHub Desktop.
Save velotiotech/d6d10ae198fd976f4050cc82d36662cb to your computer and use it in GitHub Desktop.
render(){
return (
<View style={styles.container}>
{this.state.authQRCode ?
<AuthQRCode
hideAuthQRCode = {this.hideAuthQRCode}
qrScanData = {this.qrScanData}
/>
:
<View style={{marginVertical: 10}}>
<Button title="Auth SSH Login" onPress={this.showAuthQRCode} />
<View style={{margin:10}} />
<Button title="Sign Out" onPress={this.signout} />
</View>
}
</View>
);
}
const scanCode = e.data.split(':');
if(scanCode.length <3){
throw "invalid qr code";
}
const [appstring,authcode,shacode] = scanCode;
if(appstring !== "qrauth"){
throw "Not a valid app qr code";
}
const authsession = await Auth.currentSession();
const jwtToken = authsession.getIdToken().jwtToken;
const response = await axios({
url : "https://API_GATEWAY_URL/v1/app/sshqrauth/qrauth",
method : "post",
headers : {
Authorization : jwtToken,
'Content-Type' : 'application/json'
},
responseType: "json",
data : {
authcode,
shacode
}
});
if(response.data.status === 200){
rescanQRCode=false;
setTimeout(this.hideAuthQRCode, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment