Arslanşah ile Giriş Eklendi
This commit is contained in:
parent
ab0198060e
commit
083cb13c39
39
src/App.js
39
src/App.js
@ -7,32 +7,31 @@ import Pages from './components/Pages';
|
|||||||
import Left from './components/patchs/Left';
|
import Left from './components/patchs/Left';
|
||||||
const cookie = new Cookies();
|
const cookie = new Cookies();
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col w-full'>
|
<GSProvider>
|
||||||
{/* <Navbar/> */}
|
<div className='flex flex-col w-full'>
|
||||||
<div className='flex h-full'>
|
{/* <Navbar/> */}
|
||||||
<div className='flex gap-4 m-auto page-container pt-6'>
|
<div className='flex h-full'>
|
||||||
<div className='flex w-3/12 overflow-visible'>
|
<div className='flex gap-4 m-auto page-container pt-6'>
|
||||||
<div className='flex flex-col gap-4 h-24 sticky w-full'>
|
<div className='flex w-3/12 overflow-visible'>
|
||||||
<Left/>
|
<div className='flex flex-col gap-4 h-24 sticky w-full'>
|
||||||
|
<Left/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='flex w-1/2 h-full mb-8 justify-center'>
|
||||||
|
<Pages/>
|
||||||
|
</div>
|
||||||
|
<div className='flex flex-col gap-4 h-0 sticky w-3/12 top-20'>
|
||||||
|
{/* {rightMenu} */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex w-1/2 h-full mb-8 justify-center'>
|
<div id='screen-popup' className='hidden fixed w-full h-full justify-center items-center'>
|
||||||
<Pages/>
|
{/* {popup} */}
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col gap-4 h-0 sticky w-3/12 top-20'>
|
|
||||||
{/* {rightMenu} */}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id='screen-popup' className='hidden fixed w-full h-full justify-center items-center'>
|
|
||||||
{/* {popup} */}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</GSProvider>
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// <GSProvider>
|
|
||||||
// </GSProvider>
|
|
||||||
@ -4,6 +4,7 @@ import Books from './books/pages/Books';
|
|||||||
import Book from './books/pages/Book';
|
import Book from './books/pages/Book';
|
||||||
import Publish from './quotes/pages/Publish';
|
import Publish from './quotes/pages/Publish';
|
||||||
import Page from './home/Page';
|
import Page from './home/Page';
|
||||||
|
import Login from './logins/Login';
|
||||||
|
|
||||||
export default function Pages() {
|
export default function Pages() {
|
||||||
return (
|
return (
|
||||||
@ -12,6 +13,7 @@ export default function Pages() {
|
|||||||
<Route path='/books' element={<Books/>} />
|
<Route path='/books' element={<Books/>} />
|
||||||
<Route path='/book/:id' element={<Book/>} />
|
<Route path='/book/:id' element={<Book/>} />
|
||||||
<Route path='/publish' element={<Publish/>}/>
|
<Route path='/publish' element={<Publish/>}/>
|
||||||
|
<Route path='/login' element={<Login/>} />
|
||||||
</Routes>
|
</Routes>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { FetchPOST } from '../../../middlewares/Fetch';
|
import { FetchPOST } from '../../../middlewares/Fetch';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import Cookies from 'universal-cookie';
|
||||||
|
|
||||||
export default function Books() {
|
export default function Books() {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|||||||
29
src/components/logins/Login.jsx
Normal file
29
src/components/logins/Login.jsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import React, { useContext, useEffect, useState } from 'react'
|
||||||
|
import { FetchPOST } from '../../middlewares/Fetch'
|
||||||
|
import { GSContext } from '../../middlewares/GlobalStore';
|
||||||
|
import { checkLogin } from '../../middlewares/logins/Check';
|
||||||
|
|
||||||
|
export default function Login() {
|
||||||
|
const {data} = useContext(GSContext);
|
||||||
|
const [secure, setSecure] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
checkLogin().then(res => {
|
||||||
|
setSecure(res.secure);
|
||||||
|
});
|
||||||
|
},[secure]);
|
||||||
|
|
||||||
|
if(secure === true){
|
||||||
|
return(
|
||||||
|
<div className='flex items-center justify-center p-4 bg-pc rounded-2xl'>
|
||||||
|
<p>Zaten giriş yaptınız.</p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='flex'>
|
||||||
|
<a href={`${data.protocol}//${data.back_end}/api/v1/logins/oauth/mastodon/login`} className='p-4 bg-pc'>Arslanşah ile giriş yap</a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@ -1,12 +1,32 @@
|
|||||||
import React from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
|
import { checkLogin } from '../../middlewares/logins/Check'
|
||||||
|
|
||||||
function Left() {
|
function Left() {
|
||||||
|
const [secure, setSecure] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
checkLogin().then(res => {
|
||||||
|
setSecure(res.secure);
|
||||||
|
setLoading(true);
|
||||||
|
});
|
||||||
|
},[secure]);
|
||||||
|
|
||||||
|
if(loading === false){
|
||||||
|
return(<></>)
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col gap-2'>
|
<div className='flex flex-col gap-2'>
|
||||||
<div className='flex flex-col gap-2'>
|
<div className='flex flex-col gap-2'>
|
||||||
<a className='w-full p-4 bg-gray-200 cursor-pointer rounded-2xl hover:bg-gray-300' onClick={() => window.history.back()}>Geri Git</a>
|
<a className='w-full p-4 bg-gray-200 cursor-pointer rounded-2xl hover:bg-gray-300' onClick={() => window.history.back()}>Geri Git</a>
|
||||||
<Link to={"/publish"} className='w-full p-4 bg-gray-200 rounded-2xl hover:bg-gray-300'>Gönderi Oluştur</Link>
|
{
|
||||||
|
(secure === true) ?
|
||||||
|
<Link to={"/publish"} className='w-full p-4 bg-gray-200 rounded-2xl hover:bg-gray-300'>Gönderi Oluştur</Link>
|
||||||
|
:
|
||||||
|
<Link to={"/login"} className='w-full p-4 bg-gray-200 rounded-2xl hover:bg-gray-300'>Giriş Yap</Link>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col bg-gray-200 overflow-hidden rounded-lg'>
|
<div className='flex flex-col bg-gray-200 overflow-hidden rounded-lg'>
|
||||||
<Link to={"/"} className='p-3 hover:bg-gray-300'>Anasayfa</Link>
|
<Link to={"/"} className='p-3 hover:bg-gray-300'>Anasayfa</Link>
|
||||||
|
|||||||
@ -1,9 +1,21 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { FetchPOST } from '../../../middlewares/Fetch';
|
import { FetchPOST } from '../../../middlewares/Fetch';
|
||||||
|
import { checkLogin } from '../../../middlewares/logins/Check';
|
||||||
|
|
||||||
export default function Publish() {
|
export default function Publish() {
|
||||||
const [books, setBooks] = useState([]);
|
const [books, setBooks] = useState([]);
|
||||||
const [selectedBook, setSelectedBook] = useState(null);
|
const [selectedBook, setSelectedBook] = useState(null);
|
||||||
|
const [secure, setSecure] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
checkLogin().then(res => {
|
||||||
|
setSecure(res.secure);
|
||||||
|
});
|
||||||
|
},[secure]);
|
||||||
|
|
||||||
|
if(secure === false){
|
||||||
|
return(<></>);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col gap-4 w-full'>
|
<div className='flex flex-col gap-4 w-full'>
|
||||||
|
|||||||
@ -2,12 +2,17 @@ import { createContext, useContext, useEffect, useState } from 'react';
|
|||||||
|
|
||||||
const GSContext = createContext();
|
const GSContext = createContext();
|
||||||
|
|
||||||
const GSProvider = ({ children, data, locales }) => {
|
const GSProvider = ({ children }) => {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const data = {
|
||||||
|
protocol: window.location.protocol,
|
||||||
|
back_end: "localhost:3001",
|
||||||
|
front_end: "localhost:3000"
|
||||||
|
};
|
||||||
|
|
||||||
if(loading === false){
|
if(loading === false){
|
||||||
return (
|
return (
|
||||||
<GSContext.Provider>
|
<GSContext.Provider value={{data}}>
|
||||||
{children}
|
{children}
|
||||||
</GSContext.Provider>
|
</GSContext.Provider>
|
||||||
);
|
);
|
||||||
|
|||||||
21
src/middlewares/logins/Check.jsx
Normal file
21
src/middlewares/logins/Check.jsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { FetchPOST } from "../Fetch";
|
||||||
|
|
||||||
|
export async function checkLogin() {
|
||||||
|
const data = {
|
||||||
|
secure: false
|
||||||
|
};
|
||||||
|
|
||||||
|
await FetchPOST({
|
||||||
|
port: 3001,
|
||||||
|
pathname: "/api/v1/logins/normal/verify"
|
||||||
|
}).then(res => {
|
||||||
|
if(res.Status = 200 && res.Token){
|
||||||
|
console.log(res);
|
||||||
|
data.secure = true;
|
||||||
|
}else{
|
||||||
|
data.secure = false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user