add new yandex auth
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { useSearchParams, useRouter } from 'next/navigation';
|
||||
import styles from '@/app/styles/module/login.module.scss'
|
||||
|
||||
export default function YandexCallback() {
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const code = searchParams.get('code');
|
||||
const error = searchParams.get('error');
|
||||
|
||||
if (error) {
|
||||
console.error('Ошибка авторизации:', error);
|
||||
router.push('/login?error=yandex_denied');
|
||||
return;
|
||||
}
|
||||
|
||||
if (code) {
|
||||
console.log('получаю код');
|
||||
console.log(code);
|
||||
fetch('/api/auth/yandex/callback', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ code })
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
console.log(data);
|
||||
console.log('all ok');
|
||||
/* router.push('/dashboard'); */
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [searchParams, router]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`${styles['login-container-wrapper']}`}
|
||||
>
|
||||
<div
|
||||
className="loading-animation"
|
||||
>
|
||||
<div
|
||||
className="global-spinner large"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import VKLogin from '@/app/components/VKLogin';
|
||||
import YandexAuthWithScript from '@/app/components/YandexLogin';
|
||||
import { getHealt } from '@/app/actions/action';
|
||||
import { Suspense } from 'react';
|
||||
import {YandexLoginButton} from '@/app/components/YandexLoginButton';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Login',
|
||||
@@ -51,7 +52,7 @@ export default function Page() {
|
||||
<VKLogin />
|
||||
</div>
|
||||
<div>
|
||||
<YandexAuthWithScript />
|
||||
<YandexLoginButton />
|
||||
</div>
|
||||
<div className={`${styles['register-link']}`}>
|
||||
<p>{t('no-account')}?
|
||||
|
||||
Reference in New Issue
Block a user