Commit 146d7798 authored by KangMin An's avatar KangMin An
Browse files

Merge branch 'who' into premaster

parents 358a25fe 8c1c74f5
......@@ -57,5 +57,6 @@
"last 1 firefox version",
"last 1 safari version"
]
}
},
"proxy": "http://localhost:4500"
}
import React from 'react'
import { Swal } from 'sweetalert2';
export function checkCookies() {
const acctoken_cookies = document.cookie.split('=')[1];
return acctoken_cookies;
}
export function deleteCookie (name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1999 00:00:10 GMT;';
Swal.fire({
title: '로그아웃 성공!',
text: '🙏 안녕히 가세요 🙏',
icon: 'warning',
customClass: 'swal-wide',
confirmButtonText: '확인',
}).then((res) => {
if (res.isConfirmed) {
window.location.replace('/')
}
else {
window.location.replace('/')
}
})
}
\ No newline at end of file
import React from 'react';
import { Redirect, Route } from 'react-router-dom';
import { isLogined } from '../utils/Auth';
import { isLogined } from './Auth';
function PrivateRoute({ path, children }) {
if (isLogined()) {
......
......@@ -2,6 +2,7 @@ import React, { useState } from 'react';
import '../App.css'
import { Form, Button, Row, Col, Card, Alert, FloatingLabel } from 'react-bootstrap';
import { LoginWithKakao } from '../utils/Oauth';
import axios from 'axios';
function LoginComp() {
......@@ -53,9 +54,17 @@ function LoginComp() {
function handleChange(event) {
setEmailAddress(event.target.value)
console.log(emailAddress)
}
console.log(emailAddress)
async function handleSubmit(event) {
event.preventDefault();
const res = await axios.post("/api/login", { email: emailAddress })
console.log(res)
}
return (
<Row className='text-center w-100 my-2'>
<Card style={cardstyled}>
......@@ -89,7 +98,7 @@ function LoginComp() {
}
</Row>
<Form style={inboxstyled}>
<Form style={inboxstyled} onSubmit={handleSubmit}>
<FloatingLabel
controlId="floatingInput"
label="Email"
......@@ -97,7 +106,7 @@ function LoginComp() {
<Form.Control type="email" placeholder="Email" onChange={handleChange} />
</FloatingLabel>
<Button variant='light' className='mt-3' id='formbtn' onClick={CheckEmailSend}>
<Button variant='light' className='mt-3' id='formbtn' onClick={CheckEmailSend} type='submit'>
LOGIN
</Button>
</Form>
......
......@@ -5,6 +5,9 @@ import '../App.css'
import UserInfo from './UserInfo';
import { kakaoLogout } from '../utils/Oauth';
import axios from 'axios';
import { Swal } from 'sweetalert2';
import { deleteCookie } from '../utils/Cookies';
import { checkCookies } from './../utils/Cookies';
function MainLayer() {
......@@ -33,6 +36,7 @@ function MainLayer() {
color: 'white'
}
const logined = localStorage.getItem('nickname')
const [airUsing, setAirUsing] = useState(false)
......@@ -51,6 +55,9 @@ function MainLayer() {
}
});
return (
<Col>
<Row className='d-flex align-items-center m-auto w-100 p-0'>
......@@ -63,7 +70,7 @@ function MainLayer() {
<UserInfo />
</Row>
{logined &&
{checkCookies() &&
<Form
key='checkbox' className="d-flex justify-content-center w-100" style={{ flexDirection: 'row-reverse' }}>
<Form.Check
......@@ -78,9 +85,9 @@ function MainLayer() {
<Row className='d-flex justify-content-center align-items-center my-2 mx-auto w-100'>
<ButtonGroup vertical className='m-auto' style={{ width: '100%', flexDirection: 'column' }}>
{logined ?
{checkCookies() ?
//true
<Button variant='light' style={btnstyled} onClick={kakaoLogout}>
<Button variant='light' style={btnstyled} onClick={kakaoLogout || deleteCookie('acs_token')}>
로그아웃
</Button>
:
......@@ -91,7 +98,7 @@ function MainLayer() {
</Link>
</Button>
}
{!logined &&
{!checkCookies() &&
<Button variant='light' style={btnstyled}>
<Link to='/signup' id='btnlink'>
회원가입
......
......@@ -2,6 +2,7 @@ import React, { useState } from 'react'
import '../App.css'
import { Form, Button, Row, Col, Card, Alert, FloatingLabel } from 'react-bootstrap';
import { LoginWithKakao } from '../utils/Oauth';
import axios from 'axios';
function SignupComp() {
......@@ -28,7 +29,7 @@ function SignupComp() {
}
const initValues = {
name: '',
nick_name: '',
email: ''
}
......@@ -43,55 +44,14 @@ function SignupComp() {
function handleChange(event) {
const { name, value } = event.target
setFormValues({ ...formValues, [name]: value })
console.log('???', formValues)
}
console.log('???', formValues)
function CheckUserExist() {
localStorage.setItem('signup_username', formValues.name)
localStorage.setItem('signup_email_Address', formValues.email)
const signUser = localStorage.getItem('signup_username')
const signEmail = localStorage.getItem('signup_email_Address').split('@')[1]
if (signEmail && signUser) {
setAlertShow(true)
setUserExist(!userExist)
}
else
if (!signEmail) {
setAlertShow(false)
// setUserExist(true)
}
async function handleSubmit(event) {
event.preventDefault();
await axios.post("/api/signup", formValues)
}
function handleSubmit(event) {
const form = event.currentTarget;
console.log('formValues', formValues);
console.log('formValues.values', Object.values(formValues)[0].length);
// console.log(form)
// if (Object.values(formValues)[0].length !== 0) { //form.checkValidity() === false
// event.preventDefault();
// event.stopPropagation();
// }
console.log(validated)
setValidated(true);
// const form = event.current
// setFormError(validate(formValues))
// setIsSubmit(true)
}
function handleClickSubm() {
// setEmailSubm(true);
const subm = document.getElementById("subm-mailSent");
subm.style.visibility = 'visible'
// const aftermail = document.getElementById('AftermailSent');
// aftermail.style.display = ''
}
return (
<Row className='text-center w-100 my-2'>
......@@ -129,14 +89,13 @@ function SignupComp() {
<Form style={inboxstyled} onSubmit={handleSubmit}>
<FloatingLabel
controlId="floatingInput"
label="Name"
label="Nickname"
className='mb-3'
>
<Form.Control
type="text"
name="name"
placeholder="Name"
value={formValues.name}
name="nick_name"
placeholder="Nickname"
onChange={handleChange}
required
/>
......@@ -149,14 +108,13 @@ function SignupComp() {
type="email"
name="email"
placeholder="Email Address"
value={formValues.email}
onChange={handleChange}
required
/>
</FloatingLabel>
<Button variant='light' className='mt-3' id='formbtn' type='submit' onClick={CheckUserExist}>
{/* type="submit" */}
<Button variant='light' className='mt-3' id='formbtn' type='submit'>
{/* onClick={CheckUserExist} */}
Sign Up
</Button>
</Form>
......
......@@ -2,6 +2,7 @@ import React, { useState } from 'react'
import { Row, Card, Button, Col, Modal } from 'react-bootstrap';
import '../App.css'
import { Link } from 'react-router-dom';
import { checkCookies } from './../utils/Cookies';
function UserInfo() {
......@@ -44,7 +45,7 @@ function UserInfo() {
<Card style={cardstyled} id='localName'>
<Card.Title>
<strong>
{nickname ?
{checkCookies() ?
<h2>
{`${nickname}`}
</h2>
......@@ -76,7 +77,7 @@ function UserInfo() {
</p>
}
</Card.Subtitle>
{nickname &&
{checkCookies() &&
<Button variant='light' className='m-auto d-flex' style={btnstyled2}>
<Link to='/edit' className='w-100' style={{ textDecoration: 'none', color: 'rgb(110, 189, 142)' }}>
변경
......@@ -84,7 +85,7 @@ function UserInfo() {
</Button>
}
</Row>
{nickname &&
{checkCookies() &&
<p className='w-100 justify-content-center m-auto'>
<hr />
......
......@@ -32,31 +32,33 @@ function Home() {
padding: '0'
}
const getusername = axios.get(`/api/user`)
console.log(getusername)
async function test() {
const res = await axios.get("/api/user-info", { withCredentials: true })
console.log("@@@@", res)
}
test()
return (
<Container className='m-auto d-flex position-relative'
style={{ flexDirection: 'column' }} fluid>
<Row className='d-flex'>
<Row style={constyled} className='m-auto'>
<Col xs={12} md={6} className='d-flex justify-content-center' id='stickyy'>
<Row style={col1sty} className='m-auto'>
<MainLayer />
</Row>
</Col>
<Col md={6} style={col2sty}>
{/* <TimeNow /> */}
<EueSuggest />
<ChartLine />
<ChartDoughnut />
<Donation />
</Col>
</Row>
<Container className='m-auto d-flex position-relative'
style={{ flexDirection: 'column' }} fluid>
<Row className='d-flex'>
<Row style={constyled} className='m-auto'>
<Col xs={12} md={6} className='d-flex justify-content-center' id='stickyy'>
<Row style={col1sty} className='m-auto'>
<MainLayer />
</Row>
</Col>
<Col md={6} style={col2sty}>
{/* <TimeNow /> */}
<EueSuggest />
<ChartLine />
<ChartDoughnut />
<Donation />
</Col>
</Row>
</Container>
</Row>
</Container>
);
}
......
......@@ -18,7 +18,9 @@ const app = express();
app.set("view engine", "pug");
app.set("views", path.join(__dirname, "views"));
app.use(cors());
app.use(cors({
credentials: true
}));
app.use(helmet());
app.use(cookieParser());
app.use(express.json());
......
......@@ -148,7 +148,7 @@ export const getConfirm = async (req, res) => {
res
.status(server_status.code.ok)
.cookie("acs_token", accessT)
.redirect("/api");
.redirect("http://localhost:3000/");
} catch (err) {
res
.status(server_status.code.err)
......
......@@ -20,6 +20,8 @@ export const onlyPrivate = (req, res, next) => {
cookies: { acs_token },
} = req;
console.log('@@@@@@@@@@@@@@',req.cookies);
try {
const acs_decode = jwt.verify(acs_token, envs.secretKey.access_token);
next();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment