feat(webui): add a member by provider subject or email
POST /api/orgs/{id}/members binds a person by subject, or by email as a
placeholder. The first sign-in whose provider vouches for that email
claims it: the State Store moves the binding onto the provider's subject
in one statement, so a second account with the same address finds
nothing to claim and later sign-ins rest on the subject alone.
This commit is contained in:
1 parent
9e1a40ce99
commit
37cbf2ef47
17 files changed
+2085
-1505
No files matched your search
@@ -163,6 +163,14 @@ export const api = {
|
||||
}),
|
||||
orgMembers: <T = unknown>(id: string) =>
|
||||
request<T>(`/api/orgs/${encodeURIComponent(id)}/members`),
|
||||
addOrgMember: <T = unknown>(
|
||||
id: string,
|
||||
member: { subject?: string; email?: string; role: string },
|
||||
) =>
|
||||
request<T>(`/api/orgs/${encodeURIComponent(id)}/members`, {
|
||||
method: "POST",
|
||||
body: member,
|
||||
}),
|
||||
setOrgMember: <T = unknown>(
|
||||
id: string,
|
||||
identity: string,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Plus } from "@lucide/vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import {
|
||||
Select,
|
||||
@@ -36,6 +37,10 @@ const identities = useIdentitiesStore();
|
||||
|
||||
const picked = ref("");
|
||||
const pickedRole = ref<Role>("viewer");
|
||||
// A person who has not signed in yet, named by email or by the provider's
|
||||
// subject. They sign in as this role once the provider vouches for them.
|
||||
const person = ref("");
|
||||
const personRole = ref<Role>("viewer");
|
||||
|
||||
async function load(): Promise<void> {
|
||||
if (!org.value) return;
|
||||
@@ -91,6 +96,18 @@ const add = () =>
|
||||
await load();
|
||||
});
|
||||
|
||||
const addPerson = () =>
|
||||
run("person", async () => {
|
||||
const value = person.value.trim();
|
||||
if (!org.value || !value) return;
|
||||
await api.addOrgMember(org.value.id, {
|
||||
...(value.includes("@") ? { email: value } : { subject: value }),
|
||||
role: personRole.value,
|
||||
});
|
||||
person.value = "";
|
||||
await load();
|
||||
});
|
||||
|
||||
const setRole = (member: Member, role: unknown) =>
|
||||
run(member.identity_id + (member.workspace_id ?? ""), async () => {
|
||||
if (!org.value) return;
|
||||
@@ -186,5 +203,25 @@ const remove = (member: Member) =>
|
||||
<Plus data-icon="inline-start" /> Add member
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<form class="mt-4 flex flex-wrap items-end gap-2" @submit.prevent="addPerson">
|
||||
<Input
|
||||
v-model="person"
|
||||
class="w-64"
|
||||
aria-label="Email or provider subject"
|
||||
placeholder="Email or provider subject"
|
||||
/>
|
||||
<Select v-model="personRole">
|
||||
<SelectTrigger class="w-36" aria-label="Role for the new person">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ role }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Button type="submit" size="sm" :disabled="!person.trim() || busy !== ''">
|
||||
<Plus data-icon="inline-start" /> Invite person
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user