feat: handle session selection after logging in
This commit is contained in:
@ -9,6 +9,7 @@ import { useForm, type SubmitHandler } from "react-hook-form";
|
|||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import { loginApi } from "@/api/login";
|
import { loginApi } from "@/api/login";
|
||||||
import { useAccountRepo } from "@/repository/account";
|
import { useAccountRepo } from "@/repository/account";
|
||||||
|
import { useOAuthContext } from "@/context/oauth";
|
||||||
|
|
||||||
interface LoginForm {
|
interface LoginForm {
|
||||||
email: string;
|
email: string;
|
||||||
@ -27,6 +28,8 @@ export default function LoginPage() {
|
|||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
const [success, setSuccess] = useState("");
|
const [success, setSuccess] = useState("");
|
||||||
|
|
||||||
|
const oauth = useOAuthContext();
|
||||||
|
|
||||||
const repo = useAccountRepo();
|
const repo = useAccountRepo();
|
||||||
|
|
||||||
const onSubmit: SubmitHandler<LoginForm> = useCallback(
|
const onSubmit: SubmitHandler<LoginForm> = useCallback(
|
||||||
@ -56,6 +59,8 @@ export default function LoginPage() {
|
|||||||
|
|
||||||
setSuccess("You have successfully logged in");
|
setSuccess("You have successfully logged in");
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
oauth.selectSession(response.access);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
setError(
|
setError(
|
||||||
@ -66,7 +71,7 @@ export default function LoginPage() {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[repo, reset]
|
[oauth, repo, reset]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user