Skip to content

Commit

Permalink
🐛 Fixed a magic link bug
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jul 27, 2024
1 parent 50e5cb5 commit 861f0c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions apps/magic-link/src/lib/ProviderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const ProviderModal = () => {
useEffect(() => {
const queryParams = new URLSearchParams(window.location.search);
const param = queryParams.get('redirectIngressUri');
console.log("redirectIngressUri is "+ param)
if (param !== null && param !== undefined) {
setRedirectIngressUri({
status: true,
Expand Down
8 changes: 4 additions & 4 deletions apps/webapp/src/components/Connection/ConnectionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ export default function ConnectionTable() {
const ts = connections?.map((connection) => ({
organisation: nameOrg,
app: connection.provider_slug,
vertical: connection.vertical,
vertical: connection.vertical,
category: connection.token_type,
status: connection.status,
linkedUser: connection.id_linked_user,
date: connection.created_at,
connectionToken: connection.connection_token!
}))

let INGRESS_REDIRECT : string | null = null;
let param: any;
if(config.DISTRIBUTION == 'selfhost' && config.REDIRECT_WEBHOOK_INGRESS) {
INGRESS_REDIRECT = config.REDIRECT_WEBHOOK_INGRESS
param = `&redirectIngressUri=${config.REDIRECT_WEBHOOK_INGRESS}`
}

return (
Expand Down Expand Up @@ -118,7 +118,7 @@ export default function ConnectionTable() {
</div>
</div>
<DialogFooter>
<Button variant="outline" size="sm" className="h-7 gap-1" type="submit" onClick={() => window.open(`${config.MAGIC_LINK_DOMAIN}/?uniqueLink=${uniqueLink}&redirectIngressUri=${INGRESS_REDIRECT}`, '_blank')}>
<Button variant="outline" size="sm" className="h-7 gap-1" type="submit" onClick={() => window.open(`${config.MAGIC_LINK_DOMAIN}/?uniqueLink=${uniqueLink}${param}`, '_blank')}>
<p className="mr-2">Open Link</p>
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 2C2.44772 2 2 2.44772 2 3V12C2 12.5523 2.44772 13 3 13H12C12.5523 13 13 12.5523 13 12V8.5C13 8.22386 12.7761 8 12.5 8C12.2239 8 12 8.22386 12 8.5V12H3V3L6.5 3C6.77614 3 7 2.77614 7 2.5C7 2.22386 6.77614 2 6.5 2H3ZM12.8536 2.14645C12.9015 2.19439 12.9377 2.24964 12.9621 2.30861C12.9861 2.36669 12.9996 2.4303 13 2.497L13 2.5V2.50049V5.5C13 5.77614 12.7761 6 12.5 6C12.2239 6 12 5.77614 12 5.5V3.70711L6.85355 8.85355C6.65829 9.04882 6.34171 9.04882 6.14645 8.85355C5.95118 8.65829 5.95118 8.34171 6.14645 8.14645L11.2929 3H9.5C9.22386 3 9 2.77614 9 2.5C9 2.22386 9.22386 2 9.5 2H12.4999H12.5C12.5678 2 12.6324 2.01349 12.6914 2.03794C12.7504 2.06234 12.8056 2.09851 12.8536 2.14645Z" fill="currentColor" fillRule="evenodd" clipRule="evenodd"></path></svg>
</Button>
Expand Down
10 changes: 6 additions & 4 deletions apps/webapp/src/components/Connection/CopyLinkInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ const CopyLinkInput = () => {
const [copied, setCopied] = useState(false);

const {uniqueLink} = useMagicLinkStore();
let INGRESS_REDIRECT : string | null = null;

let param: any;
if(config.DISTRIBUTION == 'selfhost' && config.REDIRECT_WEBHOOK_INGRESS) {
INGRESS_REDIRECT = config.REDIRECT_WEBHOOK_INGRESS
param = `&redirectIngressUri=${config.REDIRECT_WEBHOOK_INGRESS}`
}

const handleCopy = async () => {
try {
await navigator.clipboard.writeText(`${config.MAGIC_LINK_DOMAIN}/?uniqueLink=${uniqueLink}&redirectIngressUri=${INGRESS_REDIRECT}`);
await navigator.clipboard.writeText(`${config.MAGIC_LINK_DOMAIN}/?uniqueLink=${uniqueLink}${param}`);
toast.success("Magic link copied", {
action: {
label: "Close",
Expand All @@ -37,7 +39,7 @@ const CopyLinkInput = () => {
{uniqueLink !== 'https://' ?
<>
<Input
defaultValue={`${config.MAGIC_LINK_DOMAIN}/?uniqueLink=${uniqueLink}&redirectIngressUri=${INGRESS_REDIRECT}`}
defaultValue={`${config.MAGIC_LINK_DOMAIN}/?uniqueLink=${uniqueLink}${param}`}
readOnly
className="col-span-3 flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
/>
Expand Down

0 comments on commit 861f0c0

Please sign in to comment.