diff --git a/api-docs b/api-docs index 6d23d85..3636d4a 160000 --- a/api-docs +++ b/api-docs @@ -1 +1 @@ -Subproject commit 6d23d8547697557601eb763eb3af9d318d2610d7 +Subproject commit 3636d4a1519f412ede7ab0b301dd8ca4bdd16a7b diff --git a/components/Advertisement.tsx b/components/Advertisement.tsx index 841714b..d24bba0 100644 --- a/components/Advertisement.tsx +++ b/components/Advertisement.tsx @@ -1,21 +1,6 @@ -import { useEffect } from 'react' -import Logger from '@utils/Logger' +import AdSense from 'react-adsense' const Advertisement: React.FC = ({ size = 'short' }) => { - useEffect(() => { - if (process.env.NODE_ENV === 'production') { - window.adsbygoogle = window.adsbygoogle || [] - try { - window.adsbygoogle.push({}) - Logger.debug('Ad Pushed') - } - catch { - Logger.debug('Ad Push Fail') - } - } - - }, []) - return
= ({ size = 'short' }) => { style={size === 'short' ? { height: '90px' } : { height: '330px' }} > {process.env.NODE_ENV === 'production' ? ( - ) : ( 'Advertisement' diff --git a/package.json b/package.json index c85b06e..9790af9 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "postcss-preset-env": "6.7.0", "rc-tooltip": "5.1.1", "react": "17.0.2", + "react-adsense": "0.1.0", "react-dom": "17.0.2", "react-hotkeys": "2.0.0", "react-responsive-modal": "6.0.1", diff --git a/pages/api/auth/discord/callback.ts b/pages/api/auth/discord/callback.ts index 218eaec..352cfca 100644 --- a/pages/api/auth/discord/callback.ts +++ b/pages/api/auth/discord/callback.ts @@ -53,7 +53,11 @@ const Callback = RequestHandler().get(async (req: ApiRequest, res) => { email: user.email, username: user.username, discriminator: user.discriminator, + verified: user.verified }) + + if(userToken === 1) return res.redirect(301, 'https://docs.koreanbots.dev/bots/account/unverified') + else if(userToken === 2) return res.redirect(301, 'https://docs.koreanbots.dev/bots/account/blocked') const info = verify(userToken) res.setHeader( 'set-cookie', diff --git a/pages/bots/[id]/index.tsx b/pages/bots/[id]/index.tsx index dbae0ba..c8daf14 100644 --- a/pages/bots/[id]/index.tsx +++ b/pages/bots/[id]/index.tsx @@ -322,16 +322,11 @@ const Bots: NextPage = ({ data, desc, date, user, theme, csrfToken })

자세한 내용은 해당 글을 확인해주세요.

: '' } -
- - - -
+ + + +
- -
-
-
} diff --git a/pages/callback/discord.tsx b/pages/callback/discord.tsx index e8d19f4..0d44875 100644 --- a/pages/callback/discord.tsx +++ b/pages/callback/discord.tsx @@ -1,4 +1,4 @@ -import { NextPage} from 'next' +import { NextPage } from 'next' import dynamic from 'next/dynamic' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' diff --git a/types/index.ts b/types/index.ts index 5d7d1dc..bd1314b 100644 --- a/types/index.ts +++ b/types/index.ts @@ -130,6 +130,7 @@ export interface TokenRegister { email: string username: string discriminator: string + verified: boolean } export interface DiscordUserInfo { diff --git a/utils/Query.ts b/utils/Query.ts index 1ac3b0f..2e0862c 100644 --- a/utils/Query.ts +++ b/utils/Query.ts @@ -324,14 +324,22 @@ async function getDiscordUser(id: string):Promise { return DiscordBot.users.cache.get(id) ?? await DiscordBot.users.fetch(id, false, true).then(u => u.toJSON()).catch(()=>null) } -async function assignToken(info: TokenRegister):Promise { - let token = await knex('users').select(['token']).where({ id: info.id }) +/** + * + * @param info + * @returns 1 - UnVerified + * @returns 2 - Blocked + */ +async function assignToken(info: TokenRegister):Promise { + let token = await knex('users').select(['token', 'perm']).where({ id: info.id }) let t: string + if(!info.verified) return 1 if(token.length === 0) { t = sign({ id: info.id }, { expiresIn: '30d' }) await knex('users').insert({ token: t, date: Math.round(Number(new Date()) / 1000), id: info.id, email: info.email, tag: info.discriminator, username: info.username, discord: sign({ access_token: info.access_token, expires_in: info.expires_in, refresh_token: info.refresh_token }) }) token = await knex('users').select(['token']).where({ id: info.id }) } else await knex('users').update({ email: info.email, tag: info.discriminator, username: info.username, discord: sign({ access_token: info.access_token, expires_in: info.expires_in, refresh_token: info.refresh_token }) }).where({ id: info.id }) + if(token[0].perm !== 'user') return 2 if(!verify(token[0]?.token ?? '')) { t = sign({ id: info.id }, { expiresIn: '30d' }) await knex('users').update({ token: t }).where({ id: info.id }) diff --git a/yarn.lock b/yarn.lock index e4a6fa0..b0f2e29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7931,6 +7931,11 @@ re2@^1.15.9: nan "^2.14.2" node-gyp "^7.1.2" +react-adsense@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/react-adsense/-/react-adsense-0.1.0.tgz#f170007a9ab05ee2cd1c915cdc9788624658e3c1" + integrity sha512-VzGMH9qA7bBKAveK1joFWphhB7e2Y1ToSGzUa8b7eit3+VSkg/2MSvKxe5d/r4mcmkOHu6CHNJW0nn6RQC3IZA== + react-dom@17.0.2: version "17.0.2" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23"