mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: session auth issues
This commit is contained in:
parent
1708b36818
commit
08cc97f557
70 changed files with 607 additions and 427 deletions
|
|
@ -10,12 +10,12 @@ import * as Form from '@radix-ui/react-form'
|
|||
import { useFormik } from 'formik'
|
||||
import { getOrgLogoMediaDirectory } from '@services/media/media'
|
||||
import React from 'react'
|
||||
import { loginAndGetToken } from '@services/auth/auth'
|
||||
import { AlertTriangle } from 'lucide-react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import Link from 'next/link'
|
||||
import { signIn, useSession } from "next-auth/react"
|
||||
import { getUriWithOrg } from '@services/config/config'
|
||||
import { useLHSession } from '@components/Contexts/LHSessionContext'
|
||||
|
||||
interface LoginClientProps {
|
||||
org: any
|
||||
|
|
@ -42,7 +42,7 @@ const validate = (values: any) => {
|
|||
const LoginClient = (props: LoginClientProps) => {
|
||||
const [isSubmitting, setIsSubmitting] = React.useState(false)
|
||||
const router = useRouter();
|
||||
const session = useSession();
|
||||
const session = useLHSession();
|
||||
|
||||
const [error, setError] = React.useState('')
|
||||
const formik = useFormik({
|
||||
|
|
@ -53,19 +53,21 @@ const LoginClient = (props: LoginClientProps) => {
|
|||
validate,
|
||||
onSubmit: async (values) => {
|
||||
setIsSubmitting(true)
|
||||
//let res = await loginAndGetToken(values.email, values.password)
|
||||
const res = await signIn('credentials', {
|
||||
redirect: false,
|
||||
email: values.email,
|
||||
password: values.password,
|
||||
callbackUrl: '/'
|
||||
});
|
||||
if (res && res.error) {
|
||||
setError("Wrong Email or password");
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
else {
|
||||
router.push(`/`)
|
||||
setIsSubmitting(false)
|
||||
}else {
|
||||
await signIn('credentials', {
|
||||
email: values.email,
|
||||
password: values.password,
|
||||
callbackUrl: '/'
|
||||
});
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue