Giriş yapma halledildi.
This commit is contained in:
parent
46e8ec8188
commit
34e2b143fa
18
package-lock.json
generated
18
package-lock.json
generated
@ -14,6 +14,7 @@
|
||||
"react-dom": "^19.0.0",
|
||||
"react-router-dom": "^7.1.3",
|
||||
"react-scripts": "5.0.1",
|
||||
"universal-cookie": "^7.2.2",
|
||||
"web-vitals": "^4.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -15661,6 +15662,23 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/universal-cookie": {
|
||||
"version": "7.2.2",
|
||||
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-7.2.2.tgz",
|
||||
"integrity": "sha512-fMiOcS3TmzP2x5QV26pIH3mvhexLIT0HmPa3V7Q7knRfT9HG6kTwq02HZGLPw0sAOXrAmotElGRvTLCMbJsvxQ==",
|
||||
"dependencies": {
|
||||
"@types/cookie": "^0.6.0",
|
||||
"cookie": "^0.7.2"
|
||||
}
|
||||
},
|
||||
"node_modules/universal-cookie/node_modules/cookie": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
||||
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
"react-dom": "^19.0.0",
|
||||
"react-router-dom": "^7.1.3",
|
||||
"react-scripts": "5.0.1",
|
||||
"universal-cookie": "^7.2.2",
|
||||
"web-vitals": "^4.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
89
src/App.js
89
src/App.js
@ -1,17 +1,16 @@
|
||||
import React, { Component, useEffect } from 'react'
|
||||
import React, { Component } from 'react'
|
||||
import Header from './components/Header';
|
||||
// import NavRight from './components/NavRight';
|
||||
import NavLeft from './components/NavLeft';
|
||||
import Pages from './components/Pages';
|
||||
import ProfileMenuBox from './components/ProfileMenuBox';
|
||||
import MusikBox from './components/MusikBox';
|
||||
import Ads from './components/ads';
|
||||
import axios from 'axios';
|
||||
import BottomBox from './components/BottomBox';
|
||||
import Login from './pages/Login';
|
||||
import Auth from './middlewares/Auth';
|
||||
import Cookies from 'universal-cookie';
|
||||
const cookies = new Cookies();
|
||||
|
||||
export default class App extends Component {
|
||||
|
||||
state = {
|
||||
profile: {
|
||||
id: 1,
|
||||
@ -45,10 +44,11 @@ export default class App extends Component {
|
||||
},
|
||||
serverOptions: {
|
||||
endBack: {
|
||||
url: "http://192.168.1.15:3001"
|
||||
url: "http://192.168.1.27:3001"
|
||||
}
|
||||
},
|
||||
auth: true
|
||||
auth: false,
|
||||
runAuth: false
|
||||
};
|
||||
|
||||
functions = {
|
||||
@ -91,46 +91,53 @@ export default class App extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className='flex flex-col h-screen overflow-hidden'>
|
||||
<Header/>
|
||||
<div className='flex flex-col h-screen overflow-hidden p-4'>
|
||||
{
|
||||
this.state.auth ?
|
||||
Auth(this.state.serverOptions.endBack.url);
|
||||
|
||||
if(cookies.get("auth") === "Success"){
|
||||
return (
|
||||
<div className='flex flex-col h-screen overflow-hidden'>
|
||||
<Header/>
|
||||
<div className='flex flex-col h-screen overflow-hidden p-4'>
|
||||
<div className='flex flex-col h-screen overflow-hidden gap-4'>
|
||||
<div className='grid grid-cols-5 h-full overflow-hidden gap-4'>
|
||||
<div className='flex flex-col gap-4'>
|
||||
<div className='flex bg-white h-full rounded-2xl overflow-hidden'>
|
||||
<NavLeft state={this.state} functions={this.functions}/>
|
||||
</div>
|
||||
<div className='grid grid-cols-5 h-full overflow-hidden gap-4'>
|
||||
<div className='flex flex-col gap-4'>
|
||||
<div className='flex bg-white h-full rounded-2xl overflow-hidden'>
|
||||
<NavLeft state={this.state} functions={this.functions}/>
|
||||
</div>
|
||||
{
|
||||
Auth(this.state.serverOptions.endBack.url) ?
|
||||
<div className='flex col-span-4 h-full overflow-y-scroll bg-white rounded-2xl p-4'>
|
||||
<Pages state={this.state} functions={this.functions}/>
|
||||
</div>
|
||||
:
|
||||
<div></div>
|
||||
}
|
||||
</div>
|
||||
<div className='grid grid-cols-5 h-16 gap-4'>
|
||||
<div className='flex bg-white rounded-2xl overflow-hidden'>
|
||||
<ProfileMenuBox state={this.state} functions={this.functions}/>
|
||||
</div>
|
||||
<div className='flex col-span-4 bg-white rounded-2xl'>
|
||||
<BottomBox/>
|
||||
</div>
|
||||
<div className='flex col-span-4 h-full overflow-y-scroll bg-white rounded-2xl p-4'>
|
||||
<Pages state={this.state} functions={this.functions}/>
|
||||
</div>
|
||||
</div>
|
||||
<div className='grid grid-cols-5 h-16 gap-4'>
|
||||
<div className='flex bg-white rounded-2xl overflow-hidden'>
|
||||
<ProfileMenuBox state={this.state} functions={this.functions}/>
|
||||
</div>
|
||||
<div className='flex col-span-4 bg-white rounded-2xl'>
|
||||
<BottomBox/>
|
||||
</div>
|
||||
</div>
|
||||
:
|
||||
<div className='flex col-span-4 h-full overflow-y-scroll bg-white rounded-2xl p-4'>
|
||||
<Pages state={this.state} functions={this.functions}/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}else{
|
||||
return(
|
||||
<div className='flex flex-col h-screen overflow-hidden'>
|
||||
<Header/>
|
||||
<div className='flex flex-col h-screen overflow-hidden p-4'>
|
||||
<div className='flex flex-col h-screen overflow-hidden gap-4'>
|
||||
<div className='grid grid-cols-5 h-full overflow-hidden gap-4'>
|
||||
<div className='flex col-span-5 h-full overflow-y-scroll bg-white rounded-2xl p-4'>
|
||||
<Login state={this.state} functions={this.functions}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import React, { Component } from 'react'
|
||||
import Post from './Post';
|
||||
|
||||
export default class Overview extends Component {
|
||||
render() {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import React, { Component, useEffect } from 'react'
|
||||
import {Routes, Route} from 'react-router-dom';
|
||||
import axios from 'axios';
|
||||
|
||||
|
||||
import NotPage from '../pages/NotPage';
|
||||
@ -11,10 +10,10 @@ import Home from '../pages/Home';
|
||||
import Overview from './Overview';
|
||||
import Posts from './Posts';
|
||||
import About from './About';
|
||||
import Login from '../pages/Login';
|
||||
import Auth from '../middlewares/Auth';
|
||||
|
||||
export default class Pages extends Component {
|
||||
render() {
|
||||
render() {
|
||||
return (
|
||||
<div className='w-full'>
|
||||
<Routes>
|
||||
@ -24,7 +23,7 @@ export default class Pages extends Component {
|
||||
<Route path='posts' element={<Posts state={this.props.state} functions={this.props.functions} />}></Route>
|
||||
<Route path='about' element={<About state={this.props.state} functions={this.props.functions} />}></Route>
|
||||
</Route>
|
||||
<Route path='/login' element={<Login state={this.props.state} />} />
|
||||
{/* <Route path='/login' element={<Login state={this.props.state} />} /> */}
|
||||
<Route path='*' element={<NotPage/>}/>
|
||||
</Routes>
|
||||
</div>
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios';
|
||||
|
||||
export default function Auth(url) {
|
||||
let [auth, setAuth] = "";
|
||||
|
||||
axios.defaults.withCredentials = true;
|
||||
const result = axios.post(url + "/login/control", {
|
||||
name: "Batuhan Coşkun"
|
||||
})
|
||||
.then(res => {
|
||||
if(res.data.Status === "Success"){
|
||||
setAuth = true;
|
||||
if (window.location.pathname === "/login"){
|
||||
window.location.href = "/";
|
||||
};
|
||||
}else{
|
||||
setAuth = false;
|
||||
if(window.location.pathname !== "/login"){
|
||||
window.location.href = '/login';
|
||||
};
|
||||
};
|
||||
return setAuth;
|
||||
});
|
||||
return result;
|
||||
};
|
||||
22
src/middlewares/Auth.jsx
Normal file
22
src/middlewares/Auth.jsx
Normal file
@ -0,0 +1,22 @@
|
||||
import axios from 'axios';
|
||||
import Cookies from 'universal-cookie';
|
||||
const cookies = new Cookies();
|
||||
|
||||
|
||||
export default function Auth(url) {
|
||||
const data = {
|
||||
auth: false
|
||||
};
|
||||
|
||||
axios.defaults.withCredentials = true;
|
||||
axios.post(url + "/login/control", {
|
||||
name: "Batuhan Coşkun"
|
||||
})
|
||||
.then(res => {
|
||||
if(res.data.Status === "Success"){
|
||||
cookies.set('auth', 'Success', { path: '/' });
|
||||
}else{
|
||||
cookies.set('auth', 'Failed', { path: '/' });
|
||||
};
|
||||
});
|
||||
};
|
||||
@ -1,25 +1,13 @@
|
||||
// import axios from 'axios';
|
||||
// import React, { useEffect, useState } from 'react'
|
||||
import React, { Component } from 'react'
|
||||
|
||||
export default function Home() {
|
||||
export default class Home extends Component {
|
||||
render() {
|
||||
this.props.functions.menus.menuControl(0);
|
||||
|
||||
return (
|
||||
<div>Home</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// import React, { Component } from 'react'
|
||||
|
||||
// export default class Home extends Component {
|
||||
// render() {
|
||||
// this.props.functions.menus.menuControl(0);
|
||||
|
||||
// return (
|
||||
// <div>
|
||||
// <p>{this.props.state.menus.selected}</p>
|
||||
// </div>
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
return (
|
||||
<div>
|
||||
<p>{this.props.state.menus.selected}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
import React, { Component } from 'react'
|
||||
import axios from 'axios';
|
||||
import Cookies from 'universal-cookie';
|
||||
const cookies = new Cookies();
|
||||
|
||||
|
||||
export default class Login extends Component {
|
||||
@ -14,7 +16,9 @@ export default class Login extends Component {
|
||||
password: event.target.password.value
|
||||
})
|
||||
.then(get => {
|
||||
if(get.data.login){
|
||||
console.log(get.data);
|
||||
if(get.data.Status === "Success"){
|
||||
cookies.set('auth', 'Success', { path: '/' });
|
||||
window.location.href = "/";
|
||||
};
|
||||
});
|
||||
|
||||
@ -3,9 +3,7 @@ import ProfileDetail from '../components/ProfileDetail'
|
||||
|
||||
export default class Profile extends Component {
|
||||
render() {
|
||||
|
||||
this.props.functions.menus.menuControl(1);
|
||||
|
||||
return (
|
||||
<div className='flex flex-col w-full'>
|
||||
<ProfileDetail state={this.props.state} functions={this.props.functions}/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user