mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-07-26 11:38:13 +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() {
|
||||
const { user, loginMutation, registerMutation } = useAuth();
|
||||
const { theme } = useTheme();
|
||||
const { organizations, isLoading: orgsLoading } = useOrganization();
|
||||
|
||||
const loginForm = useForm<z.infer<typeof loginSchema>>({
|
||||
resolver: zodResolver(loginSchema),
|
||||
@@ -202,6 +203,34 @@ export default function AuthPage() {
|
||||
</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
|
||||
type="submit"
|
||||
className="w-full"
|
||||
|
||||
+25
-3
@@ -147,7 +147,16 @@ export class MemStorage implements IStorage {
|
||||
async createUser(user: InsertUser): Promise<User> {
|
||||
const id = this.userIdCounter++;
|
||||
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);
|
||||
return newUser;
|
||||
}
|
||||
@@ -177,7 +186,12 @@ export class MemStorage implements IStorage {
|
||||
async createOrganization(org: InsertOrganization): Promise<Organization> {
|
||||
const id = this.orgIdCounter++;
|
||||
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);
|
||||
return newOrg;
|
||||
}
|
||||
@@ -213,7 +227,15 @@ export class MemStorage implements IStorage {
|
||||
const id = this.domainIdCounter++;
|
||||
const createdAt = 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);
|
||||
return newDomain;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user