diff --git a/packages/next/src/views/Login/LoginForm/index.tsx b/packages/next/src/views/Login/LoginForm/index.tsx index 7b95412e418..dfda6e81f10 100644 --- a/packages/next/src/views/Login/LoginForm/index.tsx +++ b/packages/next/src/views/Login/LoginForm/index.tsx @@ -6,9 +6,9 @@ import React from 'react' const baseClass = 'login__form' const Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default -import type { FormState } from 'payload' +import type { ClientUser, FormState } from 'payload' -import { Form, FormSubmit, PasswordField, useConfig, useTranslation } from '@payloadcms/ui' +import { Form, FormSubmit, PasswordField, useAuth, useConfig, useTranslation } from '@payloadcms/ui' import { formatAdminURL } from '@payloadcms/ui/shared' import type { LoginFieldProps } from '../LoginField/index.js' @@ -50,6 +50,7 @@ export const LoginForm: React.FC<{ }) const { t } = useTranslation() + const { setUser } = useAuth() const initialState: FormState = { password: { @@ -73,6 +74,10 @@ export const LoginForm: React.FC<{ } } + const handleLogin = (data: { user: ClientUser }) => { + setUser(data.user) + } + return (