Showing
6 changed files
with
2 additions
and
90 deletions
This diff is collapsed. Click to expand it.
| ... | @@ -3,7 +3,7 @@ import { makeStyles } from '@material-ui/core/styles'; | ... | @@ -3,7 +3,7 @@ import { makeStyles } from '@material-ui/core/styles'; |
| 3 | import Paper from '@material-ui/core/Paper'; | 3 | import Paper from '@material-ui/core/Paper'; |
| 4 | import Grid from '@material-ui/core/Grid'; | 4 | import Grid from '@material-ui/core/Grid'; |
| 5 | import palette from '../../lib/styles/palette'; | 5 | import palette from '../../lib/styles/palette'; |
| 6 | -import AuthForm from '../auth/AuthForm'; | 6 | + |
| 7 | const useStyles = makeStyles((theme) => ({ | 7 | const useStyles = makeStyles((theme) => ({ |
| 8 | root: { | 8 | root: { |
| 9 | flexGrow: 1, | 9 | flexGrow: 1, | ... | ... |
| 1 | -import React from 'react'; | ||
| 2 | -import getRecommend from "../../scripts/getRecommend"; | ||
| 3 | - | ||
| 4 | -const KakaoLoginBtn = () => { | ||
| 5 | - const KakaoLogin = function () { | ||
| 6 | - window.Kakao.Auth.login({ | ||
| 7 | - success: getRecommend, | ||
| 8 | - fail: function (err) { | ||
| 9 | - console.log("login failed", err); | ||
| 10 | - } | ||
| 11 | - }) | ||
| 12 | - } | ||
| 13 | - return ( | ||
| 14 | - <div> | ||
| 15 | - <button onClick={KakaoLogin} | ||
| 16 | - a id="custom-login-btn" href="javascript:loginWithKakao()"> | ||
| 17 | - <img | ||
| 18 | - src="//k.kakaocdn.net/14/dn/btqCn0WEmI3/nijroPfbpCa4at5EIsjyf0/o.jpg" | ||
| 19 | - width="140" | ||
| 20 | - /> | ||
| 21 | - </button> | ||
| 22 | - </div> | ||
| 23 | - ); | ||
| 24 | -}; | ||
| 25 | - | ||
| 26 | -export default KakaoLoginBtn | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -75,7 +75,7 @@ const SettingContainer = ({ history }) => { | ... | @@ -75,7 +75,7 @@ const SettingContainer = ({ history }) => { |
| 75 | } | 75 | } |
| 76 | }, [dispatch, user, history]); | 76 | }, [dispatch, user, history]); |
| 77 | useEffect(() => { | 77 | useEffect(() => { |
| 78 | - if (loading['profile/SYNC_BJID'] == true) { | 78 | + if (loading['profile/SYNC_BJID']) { |
| 79 | setLoading(true); | 79 | setLoading(true); |
| 80 | } else { | 80 | } else { |
| 81 | setLoading(false); | 81 | setLoading(false); | ... | ... |
| ... | @@ -9,8 +9,3 @@ export const register = ({ username, password }) => | ... | @@ -9,8 +9,3 @@ export const register = ({ username, password }) => |
| 9 | export const check = () => client.get('api/auth/check'); | 9 | export const check = () => client.get('api/auth/check'); |
| 10 | 10 | ||
| 11 | export const logout = () => client.post('/api/auth/logout'); | 11 | export const logout = () => client.post('/api/auth/logout'); |
| 12 | - | ||
| 13 | -export const kakaotoken = (kakaotoken) => | ||
| 14 | - client.post('api/auth/kakaotoken', { | ||
| 15 | - kakaotoken: kakaotoken | ||
| 16 | - }); | ... | ... |
| 1 | -const app = require('koa') | ||
| 2 | -function getRecommend(auth) { | ||
| 3 | - console.log("login success", auth); | ||
| 4 | - const host = 'https://localhost:23023'; | ||
| 5 | - const url = host+"/api/profile/recommend"; | ||
| 6 | - | ||
| 7 | - const data = { username: 'test' }; | ||
| 8 | - window.fetch(url, { | ||
| 9 | - method: "POST", | ||
| 10 | - body: JSON.stringify(data), | ||
| 11 | - headers: { | ||
| 12 | - 'Content-Type': 'application/json' | ||
| 13 | - } | ||
| 14 | - }) | ||
| 15 | - .then(res => { | ||
| 16 | - console.log(res); | ||
| 17 | - return res.json(); | ||
| 18 | - }) | ||
| 19 | - .then(shareToKakao); | ||
| 20 | -} | ||
| 21 | -const TOKEN = 'tdN03DyXDAcKGZsuiPndaU7UC2GzuEQYUhPCkDnGWXGGdiPmV15QYbFU1U5JP5EpiETIKLqOmci/RxFZTfD7FRMED0OpT+3qgEYBNf8T9/jRzHRm7rblBLtzFBVOeXeYRcluOsz4koE4JaAJaUtMtwdB04t89/1O/w1cDnyilFU=' | ||
| 22 | - | ||
| 23 | -function shareToKakao({problem_number, problem_title, solved_date}) { | ||
| 24 | - console.log('getting ready to share...'); | ||
| 25 | - const boj_link = "https://acmicpc.net/problem/" + problem_number.toString(); | ||
| 26 | - window.fetch('https://www.osstest17.ml:23023/hook', { | ||
| 27 | - method: "POST", | ||
| 28 | - body: JSON.stringify(data), | ||
| 29 | - headers: { | ||
| 30 | - 'Authorization': `Bearer ${TOKEN}` | ||
| 31 | - }, | ||
| 32 | - json: { | ||
| 33 | - "replyToken":eventObj.replyToken, | ||
| 34 | - "messages":[ | ||
| 35 | - { | ||
| 36 | - "type":"text", | ||
| 37 | - "text":"Hello, user" | ||
| 38 | - }, | ||
| 39 | - { | ||
| 40 | - "type":"text", | ||
| 41 | - "text":"May I help you?" | ||
| 42 | - } | ||
| 43 | - ] | ||
| 44 | - } | ||
| 45 | - }) | ||
| 46 | - window.Kakao.Link.sendDefault({ | ||
| 47 | - objectType: 'text', | ||
| 48 | - text: `오늘의 추천문제는 ${problem_title}`, | ||
| 49 | - link: { | ||
| 50 | - mobileWebUrl: boj_link, | ||
| 51 | - webUrl: boj_link, | ||
| 52 | - } | ||
| 53 | - }); | ||
| 54 | -} | ||
| 55 | -export { | ||
| 56 | - getRecommend as default | ||
| 57 | -}; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment