Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload #110

Merged
merged 6 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SERVER=http://ec2-3-139-101-167.us-east-2.compute.amazonaws.com:80
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@testing-library/user-event": "^12.8.3",
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"dotenv": "^8.2.0",
"moment": "^2.29.1",
"react": "^17.0.2",
"react-bootstrap": "^1.5.2",
Expand Down
36 changes: 9 additions & 27 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Character1 from './images/Character1.png';
import { useHistory } from 'react-router-dom';
import './main.css';
import Bgm from './Bgm';
require('dotenv').config();

const axios = require('axios');

Expand Down Expand Up @@ -46,8 +47,10 @@ export default function App() {
const hendleLogout = () => {
axios

.get('http://localhost:4000/user/logout', { withCredentials: true })
.then((res) => {});
.get(
`${process.env.SERVER}/user/logout`,
{withCredentials: true}
).then((res) => {})
setUserInfo({
id: null,
nickname: null,
Expand All @@ -64,18 +67,15 @@ export default function App() {
const accessTokenRequest = (accessToken) => {
// ! 유저 정보를 알려달라는 코드
axios
.get('http://localhost:4000/accessTokenHandler', {
.get(`${process.env.SERVER}/accessTokenHandler`, {
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
withCredentials: true,
})
.then((res) => {
<<<<<<< HEAD
=======
const { nickname, email, profile_image, comment, id } = res.data.data;
>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90
// !
return res.data.data;
})
Expand All @@ -99,9 +99,9 @@ export default function App() {
}, [userInfo]);

const refreshTokenRequest = () => {
// ! 일정 주기로 함수 계속 보냄
// ! 일정 주기로 함수 계속 보냄http://ec2-3-139-101-167.us-east-2.compute.amazonaws.com:80
axios
.get('http://localhost:4000/refreshTokenHandler', {
.get(`${process.env.SERVER}/refreshTokenHandler`, {
withCredentials: true,
})
.then((res) => {
Expand All @@ -115,16 +115,7 @@ export default function App() {
comment,
} = res.data.data.userInfo;

<<<<<<< HEAD
setAccessToken({ accessToken: res.data.data.accessToken });
=======

if (res.data.message !== 'ok') {}
const { nickname, email, profile_image, id,comment } = res.data.data.userInfo;
console.log(res.data.data.accessToken)
setAccessToken({accessToken:res.data.data.accessToken})

>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90
setUserInfo({
id: id,
nickname: nickname,
Expand All @@ -145,29 +136,20 @@ export default function App() {
const getAccessToken = async (authorizationCode) => {
// ! 구글 로그인
let resp = await axios.post(
'http://localhost:4000/googlelogin',
`${process.env.SERVER}/googlelogin`,
{
authorizationCode: authorizationCode,
},
{
withCredentials: true,
}
);
<<<<<<< HEAD

=======
>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90
issueAccessToken(resp.data.accessToken);
};
//구글 로그인 코드 받기--------------------------------
useEffect(() => {
const url = new URL(window.location.href);
const authorizationCode = url.searchParams.get('code');
<<<<<<< HEAD

console.log('userInfo:', userInfo);
=======
>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90
if (authorizationCode) {
getAccessToken(authorizationCode);
}
Expand Down
3 changes: 2 additions & 1 deletion src/GamePages/InGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import Words from '../Words';
import { useHistory } from 'react-router-dom';
import Logo from './components/Logo';
import Canvas from './components/Canvas3';
const socket = io.connect('http://localhost:4000', {
require('dotenv').config();
const socket = io.connect(`${process.env.SERVER}`, {
transports: ['websocket'],
path: '/socket.io',
});
Expand Down
4 changes: 2 additions & 2 deletions src/GamePages/components/Canvas.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useRef, useEffect } from 'react';
import io from 'socket.io-client';
// import './styles/board.css';

require('dotenv').config();
export default function Canvas() {
const canvasRef = useRef(null);
const colorsRef = useRef(null);
Expand Down Expand Up @@ -151,7 +151,7 @@ export default function Canvas() {
drawLine(data.x0 * w, data.y0 * h, data.x1 * w, data.y1 * h, data.color);
};

socketRef.current = io.connect('http://localhost:4000', {
socketRef.current = io.connect(`${process.env.SERVER}`, {
transports: ['websocket', 'polling'],
path: '/socket.io',
});
Expand Down
3 changes: 2 additions & 1 deletion src/GamePages/components/Canvas3.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Crayon_Blue from '../../images/crayon_blue.png';
import Crayon_Green from '../../images/crayon_green.png';
import Crayon_Yellow from '../../images/crayon_yellow.png';
import io from 'socket.io-client';
require('dotenv').config();

export default function Canvas3() {
const canvasRef = useRef(null);
Expand Down Expand Up @@ -121,7 +122,7 @@ export default function Canvas3() {
drawLine(data.x0 * w, data.y0 * h, data.x1 * w, data.y1 * h, data.color);
};

socketRef.current = io.connect('http://localhost:4000', {
socketRef.current = io.connect(`${process.env.SERVER}`, {
transports: ['websocket', 'polling'],
path: '/socket.io',
});
Expand Down
3 changes: 2 additions & 1 deletion src/MainPages/components/Signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import '../../main.css';
import logo from '../../images/mindcaptor_logo_login.png';
import { useHistory } from 'react-router-dom';
import SocialLogin from './SocialLogin';
require('dotenv').config();

const axios = require('axios');

Expand All @@ -24,7 +25,7 @@ export default function Signin({ isOpen, close, loginHandler }) {
if (e.key === 'Enter' || e.type === 'click') {
axios
.post(
'http://localhost:4000/login',
`${process.env.SERVER}/login`,
{ email, password },
{
headers: { 'Content-Type': 'application/json' },
Expand Down
4 changes: 2 additions & 2 deletions src/MainPages/components/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import '../../main.css';
import logo from '../../images/mindcaptor_logo_sign.png';
const axios = require('axios');

require('dotenv').config();
export default function Signup({ isOpen, close, idCreatedOk }) {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
Expand All @@ -26,7 +26,7 @@ export default function Signup({ isOpen, close, idCreatedOk }) {
if (e.key === 'Enter' || e.type === 'click') {
try {
const data = await axios.post(
'http://localhost:4000/signup',
`${process.env.SERVER}`,
{ email, password, nickname },
{
headers: { 'Content-Type': 'application/json' },
Expand Down
2 changes: 1 addition & 1 deletion src/MainPages/components/SocialLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

export default function SocialLogin() {
const socialLoginHandler = () => {
const url = `https://accounts.google.com/o/oauth2/auth?client_id=970331179604-upa291p2st8pmj3676qmnm4geurg21cb.apps.googleusercontent.com&redirect_uri=http://localhost:3000&response_type=code&scope=https://www.googleapis.com/auth/userinfo.profile email`;
const url = `https://accounts.google.com/o/oauth2/auth?client_id=970331179604-upa291p2st8pmj3676qmnm4geurg21cb.apps.googleusercontent.com&redirect_uri=http://mindcaptor.s3-website.ap-northeast-2.amazonaws.com&response_type=code&scope=https://www.googleapis.com/auth/userinfo.profile email`;

window.location.assign(url);
};
Expand Down
3 changes: 2 additions & 1 deletion src/MainPages/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SigninBtn from './components/SigninBtn';
import SignupBtn from './components/SignupBtn';
import Popup from 'reactjs-popup';
import 'reactjs-popup/dist/index.css';
require('dotenv').config();

const axios = require('axios');

Expand All @@ -23,7 +24,7 @@ export default function Main({ loginHandler, handleGuestLogin }) {

const guestLogIn = () => {
axios
.get('http://localhost:4000/guest',
.get(`${process.env.SERVER}/guest`,
{
withCredentials: true
})
Expand Down
33 changes: 1 addition & 32 deletions src/MyPages/MyPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Character1 from '../images/Character1.png';
import Character2 from '../images/Character2.png';
import Character3 from '../images/Character3.png';
import Character4 from '../images/Character4.png';
require('dotenv').config();

function MyPage({ accessToken, refreshTokenRequest, userInfo }) {
const PhotoData = [Character1, Character2, Character3, Character4];
Expand Down Expand Up @@ -57,33 +58,6 @@ function MyPage({ accessToken, refreshTokenRequest, userInfo }) {
console.log('photobox', isPhotoBoxOpen);
};

<<<<<<< HEAD
const MyPageSaveData = async (PhotoNum) => {
refreshTokenRequest();
const SavePhoto = await axios.post(
`http://localhost:4000/mypage/${id}/profile`,
{ new_profile: PhotoNum },
{
headers: {
Authorization: `Bearer ${accessToken.accessToken}`,
'Content-Type': 'application/json',
},
withCredentials: true,
}
);
const SaveComment = await axios.post(
`http://localhost:4000/mypage/${id}/comment`,
{ Comment: '아니라어민어리ㅏㅁㄴ얼' },
{
headers: {
Authorization: `Bearer ${accessToken.accessToken}`,
'Content-Type': 'application/json',
},
withCredentials: true,
}
);
};
=======
// const MyPageSaveData = async (PhotoNum) => {
// await refreshTokenRequest();
// const SavePhoto = await axios.post(
Expand All @@ -109,7 +83,6 @@ function MyPage({ accessToken, refreshTokenRequest, userInfo }) {
// }
// );
// };
>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90

return (
<div>
Expand All @@ -118,11 +91,7 @@ function MyPage({ accessToken, refreshTokenRequest, userInfo }) {
nowPhoto={nowPhoto}
nickname={nickname}
PhotoNum={PhotoNum}
<<<<<<< HEAD
MyPageSaveData={MyPageSaveData}
=======
// MyPageSaveData={MyPageSaveData}
>>>>>>> a5771eaba281de9abd8e0bf97642c16df821de90
/>
<content className="container">
<div className="pro_search_box">
Expand Down
2 changes: 1 addition & 1 deletion src/WaitingPages/components/CreateGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function CreateGame({ createModal, closeModal, accessToken }) {

await axios
.post(
'http://localhost:4000/room/new',
'ec2-3-139-101-167.us-east-2.compute.amazonaws.com/room/new',
{ room_name, room_pw },
{
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/WaitingPages/components/EntryGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function EntryGame({ accessToken }) {

const handleUrl = async () => {
const result = await axios.post(
'http://localhost:4000/room/join',
'ec2-3-139-101-167.us-east-2.compute.amazonaws.com/room/join',
{},
{
headers: {
Expand Down