also router.redirect
This commit is contained in:
parent
7d4fc04add
commit
bcf329ff67
|
@ -19,6 +19,8 @@ import useUser from "../../hooks/user.hook";
|
||||||
import authService from "../../services/auth.service";
|
import authService from "../../services/auth.service";
|
||||||
import toast from "../../utils/toast.util";
|
import toast from "../../utils/toast.util";
|
||||||
|
|
||||||
|
const webroot = process.env.WEBROOT || "";
|
||||||
|
|
||||||
const SignUpForm = () => {
|
const SignUpForm = () => {
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
@ -52,9 +54,9 @@ const SignUpForm = () => {
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const user = await refreshUser();
|
const user = await refreshUser();
|
||||||
if (user?.isAdmin) {
|
if (user?.isAdmin) {
|
||||||
router.replace("/admin/intro");
|
router.replace(webroot + "/admin/intro");
|
||||||
} else {
|
} else {
|
||||||
router.replace("/upload");
|
router.replace(webroot + "/upload");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(toast.axiosError);
|
.catch(toast.axiosError);
|
||||||
|
|
|
@ -7,6 +7,8 @@ import Meta from "../../components/Meta";
|
||||||
import useUser from "../../hooks/user.hook";
|
import useUser from "../../hooks/user.hook";
|
||||||
import useTranslate from "../../hooks/useTranslate.hook";
|
import useTranslate from "../../hooks/useTranslate.hook";
|
||||||
|
|
||||||
|
const webroot = process.env.WEBROOT || "";
|
||||||
|
|
||||||
export function getServerSideProps(context: GetServerSidePropsContext) {
|
export function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
return {
|
return {
|
||||||
props: { redirectPath: context.query.redirect ?? null },
|
props: { redirectPath: context.query.redirect ?? null },
|
||||||
|
@ -25,7 +27,7 @@ const SignIn = ({ redirectPath }: { redirectPath?: string }) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refreshUser().then((user) => {
|
refreshUser().then((user) => {
|
||||||
if (user) {
|
if (user) {
|
||||||
router.replace(redirectPath ?? "/upload");
|
router.replace(redirectPath ?? webroot + "/upload");
|
||||||
} else {
|
} else {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue