feat: enable company member invitations (#211)

* feat: enable company member invitations

Activate the invite form in company settings, show pending invitations,
fix the existing-user invite flow, and process invite tokens after login.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address Greptile review — MFA invite flow and secure cookie flag

Process invite token after MFA verification so MFA-enabled users
joining via invite are not silently dropped. Add secure flag on
the invite cookie when served over HTTPS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-04-09 17:08:52 +02:00
committed by GitHub
co-authored by Claude Opus 4.6
parent bb336eba88
commit e8928b7885
4 changed files with 130 additions and 33 deletions
+29 -15
View File
@@ -158,14 +158,9 @@ export function CompanyMembersSection() {
return (
<div className="space-y-6">
{/* Invite form — disabled, coming soon */}
{/* Invite form */}
{canInvite && (
<Card className="relative overflow-hidden">
<div className="absolute inset-0 bg-background/60 backdrop-blur-[1px] z-10 flex items-center justify-center">
<Badge variant="secondary" className="text-xs font-medium">
Kommer snart
</Badge>
</div>
<Card>
<CardHeader>
<CardTitle className="text-base">Bjud in till {company?.name}</CardTitle>
<CardDescription>
@@ -173,21 +168,40 @@ export function CompanyMembersSection() {
</CardDescription>
</CardHeader>
<CardContent>
<div className="flex gap-3 pointer-events-none">
<form onSubmit={handleInvite} className="flex gap-3">
<div className="flex-1">
<Label htmlFor="company-invite-email" className="sr-only">E-postadress</Label>
<Input
id="company-invite-email"
type="email"
placeholder="namn@example.com"
disabled
value={inviteEmail}
onChange={(e) => setInviteEmail(e.target.value)}
disabled={isSending}
required
/>
</div>
<Button disabled>
<Plus className="h-4 w-4 mr-1.5" />
Bjud in
<Select value={inviteRole} onValueChange={setInviteRole}>
<SelectTrigger className="w-[140px]">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="viewer">Läsbehörighet</SelectItem>
<SelectItem value="member">Medlem</SelectItem>
<SelectItem value="admin">Admin</SelectItem>
</SelectContent>
</Select>
<Button type="submit" disabled={isSending || !inviteEmail.trim()}>
{isSending ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
<>
<Plus className="h-4 w-4 mr-1.5" />
Bjud in
</>
)}
</Button>
</div>
</form>
</CardContent>
</Card>
)}
@@ -253,8 +267,8 @@ export function CompanyMembersSection() {
</CardContent>
</Card>
{/* Pending invitations — hidden while invites are disabled */}
{false && invitations.length > 0 && (
{/* Pending invitations */}
{invitations.length > 0 && (
<Card>
<CardHeader>
<CardTitle className="text-base">Väntande inbjudningar</CardTitle>