Projektarten: Login behaelt Ziel-Link, Hinweise im Ticket-Dialog
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c16049d266
commit
471c7a056d
5 files changed
+49
-7
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useNavigate, useLocation } from 'react-router-dom'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import LetterGlitch from '../components/LetterGlitch'
|
||||
import { safeReturnPath } from '../lib/returnPath'
|
||||
|
||||
export default function LoginPage() {
|
||||
const [email, setEmail] = useState('')
|
||||
@@ -13,6 +14,8 @@ export default function LoginPage() {
|
||||
|
||||
const { login, mfaPending, sendCode, verifyCode, cancelMfa } = useAuth()
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const target = safeReturnPath(location.state?.from)
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault()
|
||||
@@ -23,7 +26,7 @@ export default function LoginPage() {
|
||||
const result = await login(email, password)
|
||||
|
||||
if (result.success) {
|
||||
navigate('/tickets')
|
||||
navigate(target, { replace: true })
|
||||
} else if (result.mfaRequired) {
|
||||
if (result.error) setError(result.error)
|
||||
} else {
|
||||
@@ -52,7 +55,7 @@ export default function LoginPage() {
|
||||
const result = await verifyCode(code)
|
||||
setLoading(false)
|
||||
if (result.success) {
|
||||
navigate('/tickets')
|
||||
navigate(target, { replace: true })
|
||||
} else {
|
||||
setError(result.error)
|
||||
setCode('')
|
||||
|
||||
Reference in new issue
Block a user