-
Notifications
You must be signed in to change notification settings - Fork 29
fix: login journey #2949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dennnis-ez
wants to merge
14
commits into
main
Choose a base branch
from
fix/login_journey
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix: login journey #2949
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5c2b7fa
fix: login journey
dennnis-ez 5ee0673
chore: lint
dennnis-ez 4ea90f4
dummy to trigger CI
dennnis-ez b6044eb
chore: trigger CI
dennnis-ez 643b21b
chore: trigger CI
dennnis-ez 1202e42
fix: memberships
dennnis-ez 31fc711
fix: admin gate
dennnis-ez 641d3b3
fix(auth): return all org memberships for admins in own org
dennnis-ez c0b4282
Merge branch 'main' into fix/login_journey
dennnis-ez 292c9f5
chore: reverts accidental changes
dennnis-ez 1ca51ab
chore: reverts accidental changes
dennnis-ez 34ce44d
docs(changeset): Fixes login journey for allowed orgs
dennnis-ez 790ecf7
fix(auth): update tests for always-on WorkOS membership sync
dennnis-ez 601e73c
chore: lint
dennnis-ez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
| --- | ||
| "dashboard": patch | ||
| "server": patch | ||
| --- | ||
|
|
||
| Fixes login journey for allowed orgs |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,125 @@ | ||
| import { useSessionData } from "@/contexts/Auth"; | ||
| import { useSdkClient } from "@/contexts/Sdk"; | ||
| import { AuthLayout } from "@/pages/login/components/login-section"; | ||
| import { JourneyDemo } from "@/pages/login/components/journey-demo"; | ||
| import { | ||
| Select, | ||
| SelectContent, | ||
| SelectItem, | ||
| SelectTrigger, | ||
| SelectValue, | ||
| } from "@/components/ui/select"; | ||
| import { Button } from "@speakeasy-api/moonshine"; | ||
| import { LogOutIcon, AlertCircleIcon, BuildingIcon } from "lucide-react"; | ||
| import { useState } from "react"; | ||
|
|
||
| interface SwitchOrgProps { | ||
| gate?: boolean; | ||
| } | ||
|
|
||
| export default function SwitchOrg({ gate = false }: SwitchOrgProps) { | ||
| const client = useSdkClient(); | ||
| const { session } = useSessionData(); | ||
|
|
||
| const allOrgs = session?.organizations ?? []; | ||
|
|
||
| const [selectedOrgId, setSelectedOrgId] = useState<string>(""); | ||
| const [isSwitching, setIsSwitching] = useState(false); | ||
|
|
||
| const handleSwitch = async () => { | ||
| if (!selectedOrgId || selectedOrgId === session?.activeOrganizationId) | ||
| return; | ||
| setIsSwitching(true); | ||
| try { | ||
| await client.auth.switchScopes({ organizationId: selectedOrgId }); | ||
| window.location.replace("/"); | ||
| } finally { | ||
| setIsSwitching(false); | ||
| } | ||
| }; | ||
|
|
||
| const handleLogout = async () => { | ||
| await client.auth.logout(); | ||
| window.location.href = "/login"; | ||
| }; | ||
|
|
||
| const currentOrgName = session?.organization?.name ?? "This organization"; | ||
|
|
||
| return ( | ||
| <main className="flex min-h-screen flex-col md:flex-row"> | ||
| <JourneyDemo /> | ||
|
|
||
| <AuthLayout | ||
| topRight={ | ||
| gate ? ( | ||
| <button | ||
| onClick={handleLogout} | ||
| className="flex items-center gap-1.5 text-xs text-[#8B8684] transition-colors hover:text-slate-600" | ||
| > | ||
| <LogOutIcon className="h-3.5 w-3.5" /> | ||
| Log out | ||
| </button> | ||
| ) : undefined | ||
| } | ||
| > | ||
| <div className="flex flex-col items-center gap-3 text-center"> | ||
| <div | ||
| className={`flex h-12 w-12 items-center justify-center rounded-full ${gate ? "bg-amber-50" : "bg-blue-50"}`} | ||
| > | ||
| {gate ? ( | ||
| <AlertCircleIcon className="h-6 w-6 text-amber-500" /> | ||
| ) : ( | ||
| <BuildingIcon className="h-6 w-6 text-blue-500" /> | ||
| )} | ||
| </div> | ||
| <h1 className="text-2xl font-bold tracking-tight text-gray-900"> | ||
| {gate ? `No access for ${currentOrgName}` : "Switch organization"} | ||
| </h1> | ||
| <p className="text-sm leading-relaxed text-[#8B8684]"> | ||
| {gate | ||
| ? "This organization doesn't have access to the MCP platform. Switch to another organization to continue." | ||
| : "Select which organization you'd like to work in."} | ||
| </p> | ||
| </div> | ||
|
|
||
| <div className="flex w-full flex-col gap-3"> | ||
| <Select value={selectedOrgId} onValueChange={setSelectedOrgId}> | ||
| <SelectTrigger className="w-full"> | ||
| <SelectValue placeholder="Select an organization" /> | ||
| </SelectTrigger> | ||
| <SelectContent> | ||
| {allOrgs.map((org) => { | ||
| const isCurrent = org.id === session?.activeOrganizationId; | ||
| return ( | ||
| <SelectItem key={org.id} value={org.id} disabled={isCurrent}> | ||
| <span className="flex items-center gap-2"> | ||
| {org.name || org.slug} | ||
| {isCurrent && ( | ||
| <span className="rounded-sm bg-emerald-50 px-1.5 py-0.5 text-[10px] font-medium text-emerald-600"> | ||
| current | ||
| </span> | ||
| )} | ||
| </span> | ||
| </SelectItem> | ||
| ); | ||
| })} | ||
| </SelectContent> | ||
| </Select> | ||
|
|
||
| <Button | ||
| variant="brand" | ||
| className="w-full" | ||
| onClick={handleSwitch} | ||
| disabled={ | ||
| !selectedOrgId || | ||
| selectedOrgId === session?.activeOrganizationId || | ||
| isSwitching | ||
| } | ||
| > | ||
| {isSwitching ? "Switching…" : "Switch organization"} | ||
| </Button> | ||
| </div> | ||
| </AuthLayout> | ||
| </main> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.