mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-31 12:48:03 +00:00
Add organization selection to user registration
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/de2252c0-4da3-414b-97b5-948dbaef457c.jpg
This commit is contained in:
@@ -30,6 +30,7 @@ const registerSchema = z.object({
|
|||||||
export default function AuthPage() {
|
export default function AuthPage() {
|
||||||
const { user, loginMutation, registerMutation } = useAuth();
|
const { user, loginMutation, registerMutation } = useAuth();
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
const { organizations, isLoading: orgsLoading } = useOrganization();
|
||||||
|
|
||||||
const loginForm = useForm<z.infer<typeof loginSchema>>({
|
const loginForm = useForm<z.infer<typeof loginSchema>>({
|
||||||
resolver: zodResolver(loginSchema),
|
resolver: zodResolver(loginSchema),
|
||||||
@@ -202,6 +203,34 @@ export default function AuthPage() {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<FormField
|
||||||
|
control={registerForm.control}
|
||||||
|
name="organizationId"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Organization</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Select
|
||||||
|
disabled={orgsLoading}
|
||||||
|
onValueChange={(value) => field.onChange(parseInt(value))}
|
||||||
|
value={field.value?.toString() || ""}
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select an organization (optional)" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{organizations.map((org) => (
|
||||||
|
<SelectItem key={org.id} value={org.id.toString()}>
|
||||||
|
{org.name}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
|||||||
+25
-3
@@ -147,7 +147,16 @@ export class MemStorage implements IStorage {
|
|||||||
async createUser(user: InsertUser): Promise<User> {
|
async createUser(user: InsertUser): Promise<User> {
|
||||||
const id = this.userIdCounter++;
|
const id = this.userIdCounter++;
|
||||||
const createdAt = new Date();
|
const createdAt = new Date();
|
||||||
const newUser: User = { id, ...user, createdAt };
|
const newUser: User = {
|
||||||
|
id,
|
||||||
|
username: user.username,
|
||||||
|
password: user.password,
|
||||||
|
email: user.email,
|
||||||
|
fullName: user.fullName || null,
|
||||||
|
role: user.role || 'user',
|
||||||
|
organizationId: user.organizationId || null,
|
||||||
|
createdAt
|
||||||
|
};
|
||||||
this.usersMap.set(id, newUser);
|
this.usersMap.set(id, newUser);
|
||||||
return newUser;
|
return newUser;
|
||||||
}
|
}
|
||||||
@@ -177,7 +186,12 @@ export class MemStorage implements IStorage {
|
|||||||
async createOrganization(org: InsertOrganization): Promise<Organization> {
|
async createOrganization(org: InsertOrganization): Promise<Organization> {
|
||||||
const id = this.orgIdCounter++;
|
const id = this.orgIdCounter++;
|
||||||
const createdAt = new Date();
|
const createdAt = new Date();
|
||||||
const newOrg: Organization = { id, ...org, createdAt };
|
const newOrg: Organization = {
|
||||||
|
id,
|
||||||
|
name: org.name,
|
||||||
|
isActive: org.isActive ?? true,
|
||||||
|
createdAt
|
||||||
|
};
|
||||||
this.orgsMap.set(id, newOrg);
|
this.orgsMap.set(id, newOrg);
|
||||||
return newOrg;
|
return newOrg;
|
||||||
}
|
}
|
||||||
@@ -213,7 +227,15 @@ export class MemStorage implements IStorage {
|
|||||||
const id = this.domainIdCounter++;
|
const id = this.domainIdCounter++;
|
||||||
const createdAt = new Date();
|
const createdAt = new Date();
|
||||||
const lastUpdated = new Date();
|
const lastUpdated = new Date();
|
||||||
const newDomain: Domain = { id, ...domain, lastUpdated, createdAt };
|
const newDomain: Domain = {
|
||||||
|
id,
|
||||||
|
name: domain.name,
|
||||||
|
organizationId: domain.organizationId,
|
||||||
|
providerId: domain.providerId,
|
||||||
|
isActive: domain.isActive ?? true,
|
||||||
|
lastUpdated,
|
||||||
|
createdAt
|
||||||
|
};
|
||||||
this.domainsMap.set(id, newDomain);
|
this.domainsMap.set(id, newDomain);
|
||||||
return newDomain;
|
return newDomain;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user