Skip to content

Commit e17ebb8

Browse files
authored
Merge pull request #32 from velog-io/development
로그인 필요한 페이지에서 로그인 안내 문구
2 parents 7b5cf01 + 546a5e7 commit e17ebb8

File tree

10 files changed

+76
-14
lines changed

10 files changed

+76
-14
lines changed

packages/velog-server/src/graphql/resolvers/userResolvers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ const userResolvers: Resolvers = {
7979
checkEmailExists: async (_, { input }) => {
8080
const userService = container.resolve(UserService)
8181
const user = await userService.findByEmail(input.email)
82-
console.log('user', user)
8382
return !!user
8483
},
8584
},

packages/velog-server/src/services/UserService/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ export class UserService implements Service {
242242
try {
243243
if (ENV.dockerEnv === 'development') {
244244
console.log(`Login URL: ${ENV.clientV3Host}/email-change?code=${code}`)
245+
} else {
246+
await this.mail.sendMail({
247+
to: email,
248+
249+
...template,
250+
})
245251
}
246-
247-
await this.mail.sendMail({
248-
to: email,
249-
250-
...template,
251-
})
252252
} catch (error) {
253253
console.error('change email error', error)
254254
throw error

packages/velog-server/src/template/changeEmailTemplate.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export const changeEmailTemplate: ChangeEmailTemplateArgs = (username, email, co
99
<a href="https://velog.io">
1010
<img src="https://images.velog.io/email-logo.png" style="display: block; width: 128px; margin: 0 auto;"/>
1111
</a>
12-
<div style="max-width: 100%; width: 400px; margin: 0 auto; padding: 1rem; text-align: justify; background: #f8f9fa; border: 1px solid #dee2e6; box-sizing: border-box; border-radius: 4px; color: #868e96; margin-top: 0.5rem; box-sizing: border-box;">
13-
<b style="black">안녕하세요!</b>
14-
${username}의 이메일을 ${email}${text}하는 것을 승인하겠습니까?
12+
<div style="max-width: 100%; margin: 0 auto; padding: 1rem; text-align: justify; background: #f8f9fa; border: 1px solid #dee2e6; box-sizing: border-box; border-radius: 4px; color: #868e96; margin-top: 0.5rem; box-sizing: border-box;">
13+
<div><b style="black">안녕하세요!</b></div>
14+
<p style="word-wrap: break-word; word-break: break-all;">${username}의 이메일을 ${email}${text}하는 것을 승인하겠습니까?</p>
1515
</div>
1616
<a href="${endpoint}/email-change?code=${code}" style="text-decoration: none; width: 400px; text-align:center; display:block; margin: 0 auto; margin-top: 1rem; background: #845ef7; padding-top: 1rem; color: white; font-size: 1.25rem; padding-bottom: 1rem; font-weight: 600; border-radius: 4px;">
1717
${text}하기
@@ -25,6 +25,7 @@ export const changeEmailTemplate: ChangeEmailTemplateArgs = (username, email, co
2525
</div>
2626
</div>
2727
`
28+
2829
return {
2930
subject,
3031
body,

packages/velog-web/src/app/notifications/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import RequireLogin from '@/components/RequireLogin'
12
import NotificationList from '@/features/notification/components/NotificationList'
23
import NotificationSelector from '@/features/notification/components/NotificationSelector'
34
import NotificationTitle from '@/features/notification/components/NotificationTitle'
45
import getCurrentUser from '@/prefetch/getCurrentUser'
5-
import { notFound } from 'next/navigation'
66

77
export default async function NotificationPage() {
88
const user = await getCurrentUser()
99

1010
if (!user) {
11-
notFound()
11+
return <RequireLogin />
1212
}
1313

1414
return (

packages/velog-web/src/app/setting/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import RequireLogin from '@/components/RequireLogin'
12
import SettingEmailRow from '@/features/setting/components/SettingEmailRow'
23
import SettingEmailRulesRow from '@/features/setting/components/SettingEmailRulesRow'
34
import SettingSocialInfoRow from '@/features/setting/components/SettingSocialInfoRow'
@@ -13,7 +14,7 @@ export default async function SettingPage() {
1314
const user = await getCurrentUser()
1415

1516
if (!user) {
16-
notFound()
17+
return <RequireLogin />
1718
}
1819

1920
const velogConfig = await getVelogConfig({ username: user.username })

packages/velog-web/src/components/Error/ErrorScreenTemplate/ErrorScreenTemplate.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
display: flex;
33
width: 100%;
44
height: 100%;
5-
min-height: 100svh;
65
align-items: center;
76
justify-content: center;
87
flex-direction: column;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.block {
2+
height: 70svh;
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import RequireLogin from './RequireLogin'
2+
import { render } from '@testing-library/react'
3+
4+
describe('RequireLogin', () => {
5+
it('renders successfully', () => {
6+
render(<RequireLogin />)
7+
})
8+
})
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
'use client'
2+
3+
import styles from './RequireLogin.module.css'
4+
import { bindClassNames } from '@/lib/styles/bindClassNames'
5+
import ErrorScreenTemplate from '@/components/Error/ErrorScreenTemplate'
6+
import { UndrawLogin } from '@/assets/vectors/components'
7+
import { useModal } from '@/state/modal'
8+
import { useEffect } from 'react'
9+
import { useAuth } from '@/state/auth'
10+
import { usePathname, useRouter } from 'next/navigation'
11+
12+
const cx = bindClassNames(styles)
13+
14+
type Props = {
15+
redirectTo?: string
16+
}
17+
18+
function RequireLogin({ redirectTo }: Props) {
19+
const pathname = usePathname()
20+
const router = useRouter()
21+
const { actions } = useModal()
22+
23+
const redirectToPath = redirectTo || pathname
24+
25+
const {
26+
value: { currentUser },
27+
} = useAuth()
28+
29+
const onButtonClick = () => {
30+
actions.showModal('login', redirectToPath)
31+
}
32+
33+
useEffect(() => {
34+
if (!currentUser) return
35+
router.push(redirectToPath)
36+
}, [router, currentUser, redirectToPath])
37+
38+
return (
39+
<div className={cx('block')}>
40+
<ErrorScreenTemplate
41+
Illustration={UndrawLogin}
42+
message="로그인 후 이용해주세요."
43+
onButtonClick={onButtonClick}
44+
buttonText="로그인"
45+
/>
46+
</div>
47+
)
48+
}
49+
50+
export default RequireLogin
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './RequireLogin'

0 commit comments

Comments
 (0)