🐛 Fix confirm account flow cannot get code from qs
This commit is contained in:
parent
dad48b7a60
commit
7600e3f93d
@ -1,3 +1,5 @@
|
||||
'use client'
|
||||
|
||||
import { sni } from 'solar-js-sdk'
|
||||
import { Container, Box, Typography, CircularProgress, Alert, Collapse } from '@mui/material'
|
||||
import { useRouter } from 'next/router'
|
||||
@ -6,16 +8,18 @@ import { useEffect, useState } from 'react'
|
||||
import ErrorIcon from '@mui/icons-material/Error'
|
||||
|
||||
import 'animate.css'
|
||||
import { useSearchParams } from 'next/navigation'
|
||||
|
||||
export default function AccountConfirm() {
|
||||
const router = useRouter()
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
async function confirm() {
|
||||
try {
|
||||
await sni.post('/cgi/id/users/me/confirm', {
|
||||
code: router.query['code'] as string,
|
||||
code: searchParams.get('code'),
|
||||
})
|
||||
router.push('/')
|
||||
} catch (err: any) {
|
||||
@ -25,7 +29,7 @@ export default function AccountConfirm() {
|
||||
|
||||
useEffect(() => {
|
||||
confirm()
|
||||
}, [])
|
||||
}, [searchParams])
|
||||
|
||||
return (
|
||||
<Container
|
||||
|
@ -1,12 +1,16 @@
|
||||
'use client'
|
||||
|
||||
import { sni } from 'solar-js-sdk'
|
||||
import { Container, Box, Typography, Alert, Collapse, Button } from '@mui/material'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useState } from 'react'
|
||||
|
||||
import ErrorIcon from '@mui/icons-material/Error'
|
||||
import { useSearchParams } from 'next/navigation'
|
||||
|
||||
export default function AccountDeletion() {
|
||||
const router = useRouter()
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [busy, setBusy] = useState(false)
|
||||
@ -15,7 +19,7 @@ export default function AccountDeletion() {
|
||||
try {
|
||||
setBusy(true)
|
||||
await sni.patch('/cgi/id/users/me/deletion', {
|
||||
code: router.query['code'] as string,
|
||||
code: searchParams.get('code'),
|
||||
})
|
||||
router.push('/')
|
||||
} catch (err: any) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
'use client'
|
||||
|
||||
import { sni } from 'solar-js-sdk'
|
||||
import { Container, Box, Typography, Alert, Collapse, Button, TextField } from '@mui/material'
|
||||
import { useRouter } from 'next/router'
|
||||
@ -5,6 +7,7 @@ import { useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
|
||||
import ErrorIcon from '@mui/icons-material/Error'
|
||||
import { useSearchParams } from 'next/navigation'
|
||||
|
||||
export type SnResetPasswordForm = {
|
||||
password: string
|
||||
@ -12,6 +15,7 @@ export type SnResetPasswordForm = {
|
||||
|
||||
export default function AccountPasswordReset() {
|
||||
const router = useRouter()
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
const { handleSubmit, register } = useForm<SnResetPasswordForm>()
|
||||
|
||||
@ -22,7 +26,7 @@ export default function AccountPasswordReset() {
|
||||
try {
|
||||
setBusy(true)
|
||||
await sni.patch('/cgi/id/users/me/password-reset', {
|
||||
code: router.query['code'] as string,
|
||||
code: searchParams.get('code'),
|
||||
new_password: data.password,
|
||||
})
|
||||
router.push('/')
|
||||
|
Loading…
x
Reference in New Issue
Block a user