diff --git a/ui/app/_register/page.tsx b/ui/app/_register/page.tsx deleted file mode 100644 index f88bf940..00000000 --- a/ui/app/_register/page.tsx +++ /dev/null @@ -1,172 +0,0 @@ -'use client'; - -import { useAuth } from '@/lib/auth/AuthContext'; -import { Button } from '@/components/ui/button'; -import { Input } from '@/components/ui/input'; -import { Label } from '@/components/ui/label'; -import { useRouter } from 'next/navigation'; -import { useState } from 'react'; -import { toast } from 'sonner'; -import Link from 'next/link'; -import { ArrowUpCircleIcon } from 'lucide-react'; -import { registerUser, SchemaRegisterProps } from '@/lib/api/services/auth'; - -export default function NostrRegisterPage() { - const router = useRouter(); - const { connectNostr } = useAuth(); - const [isLoading, setIsLoading] = useState(false); - const [formData, setFormData] = useState({ - npub: '', - name: '', - }); - - const handleInputChange = (e: React.ChangeEvent) => { - const { name, value } = e.target; - setFormData((prev) => ({ ...prev, [name]: value })); - }; - - const handleNostrConnect = async () => { - setIsLoading(true); - try { - const publicKey = await connectNostr(); - if (publicKey) { - setFormData((prev) => ({ ...prev, npub: publicKey })); - toast.success( - 'Nostr connected. Please enter your name to complete registration.' - ); - } else { - toast.error( - 'Failed to connect. Please make sure your Nostr extension is installed and enabled.' - ); - } - } catch (error) { - console.error('Nostr connection error:', error); - toast.error('Failed to connect to Nostr. Please try again.'); - } finally { - setIsLoading(false); - } - }; - - const handleRegister = async (e: React.FormEvent) => { - e.preventDefault(); - - if (!formData.npub || formData.npub.length < 10) { - toast.error('Please enter a valid Nostr public key'); - return; - } - - if (!formData.name) { - toast.error('Please enter your name'); - return; - } - - setIsLoading(true); - try { - // Register the user - const result = await registerUser(formData); - console.log('Registration successful:', result); - toast.success('Account created successfully'); - router.push('/login'); - } catch (error) { - console.error('Registration error:', error); - toast.error('Registration failed. Please try again.'); - } finally { - setIsLoading(false); - } - }; - - return ( -
-
-
-
-
-
- -
- -
- Routstr - -

Create an Account

-
- Already have an account?{' '} - - Sign in - -
-
-
-
- - -
-
- - -
- -
-
- - Or - -
-
- -
-
-
-
- By clicking create account, you agree to our{' '} - Terms of Service and{' '} - Privacy Policy. -
-
-
-
- ); -} diff --git a/ui/lib/auth/ProtectedRoute.tsx b/ui/lib/auth/ProtectedRoute.tsx index b5deb7da..e4ab5eea 100644 --- a/ui/lib/auth/ProtectedRoute.tsx +++ b/ui/lib/auth/ProtectedRoute.tsx @@ -9,7 +9,7 @@ export function ProtectedRoute({ children }: { children: React.ReactNode }) { const pathname = usePathname(); useEffect(() => { - const publicPaths = ['/', '/login', '/_register', '/unauthorized']; + const publicPaths = ['/', '/login', '/unauthorized']; const isPublicPath = publicPaths.some((path) => path === '/' ? pathname === '/' : pathname.startsWith(path) );