Skip to content

Commit

Permalink
Merge pull request #1087 from e-mission/onboarding_routing_sept_2023
Browse files Browse the repository at this point in the history
Final showstopper issue
  • Loading branch information
shankari authored Oct 28, 2023
2 parents 5265e20 + 17657a9 commit 342e190
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions www/js/components/QrCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export function shareQR(message) {
}

const QrCode = ({ value, ...rest }) => {
let hasLink = value.toString().includes("//");
if(!hasLink) {
value = "emission://login_token?token=" + value;
}

return <QRCode className="qr-code" value={value} style={[{ width: '100%', height: '100%' }, rest.style] as any} {...rest} />;
};

Expand Down
2 changes: 1 addition & 1 deletion www/js/control/ProfileSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ProfileSettings = () => {
const StartPrefs = getAngularService('StartPrefs');

//functions that come directly from an Angular service
const editCollectionConfig = () => setEditCollection(true);
const editCollectionConfig = () => setEditCollectionVis(true);
const editSyncConfig = () => setEditSync(true);

//states and variables used to control/create the settings
Expand Down
18 changes: 14 additions & 4 deletions www/js/onboarding/WelcomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Button, Dialog, Divider, IconButton, Surface, Text, TextInput, Touchabl
import color from 'color';
import { initByUser } from '../config/dynamicConfig';
import { AppContext } from '../App';
import { displayError } from "../plugin/logger";
import { displayError, logDebug } from "../plugin/logger";
import { onboardingStyles } from './OnboardingStack';
import { Icon } from '../components/Icon';

Expand All @@ -20,12 +20,22 @@ const WelcomePage = () => {
const [infoPopupVis, setInfoPopupVis] = useState(false);
const [existingToken, setExistingToken] = useState('');

const checkURL = function (result) {
let notCancelled = result.cancelled == false;
let isQR = result.format == "QR_CODE";
let hasPrefix = result.text.split(":")[0] == "emission";
let hasToken = result.text.includes("login_token?token");

logDebug("QR code " + result.text + " checks: cancel, format, prefix, params " + notCancelled + isQR + hasPrefix + hasToken);

return notCancelled && isQR && hasPrefix && hasToken;
}

const scanCode = function() {
window.cordova.plugins.barcodeScanner.scan(
window['cordova'].plugins.barcodeScanner.scan(
function (result) {
console.debug("scanned code", result);
if (result.format == "QR_CODE" &&
result.cancelled == false) {
if (checkURL(result)) {
let text = result.text.split("=")[1];
console.log("found code", text);
loginWithToken(text);
Expand Down

0 comments on commit 342e190

Please sign in to comment.