-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat] 로그인 페이지 구현
- Loading branch information
Showing
15 changed files
with
138 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,13 +32,16 @@ export class AuthService { | |
|
||
async createGuestUser() { | ||
const randomNum = Math.floor(Math.random() * 10000); | ||
const response = await fetch('https://api.thecatapi.com/v1/images/search'); | ||
const catImageUrl = (await response.json())[0].url; | ||
|
||
const guestUser = { | ||
username: `guest_${randomNum}`, | ||
password: `guest_password_${randomNum}`, | ||
email: `[email protected]`, | ||
nickname: `guest_${randomNum}`, | ||
introduce: `게스트 사용자입니다. `, | ||
profileImageUrl: `https://cataas.com/cat?${Date.now()}`, | ||
profileImageUrl: catImageUrl, | ||
}; | ||
const user = await this.userService.findUserByUsername(guestUser.username); | ||
if (!user) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { guestLogin } from '@/api/auth'; | ||
import ChevronRight from '@/assets/icons/chevron-right.svg?react'; | ||
|
||
function GuestLogin() { | ||
const handleGuestLogin = () => { | ||
guestLogin(); | ||
}; | ||
|
||
return ( | ||
<span | ||
className="mt-3 flex items-center gap-1.5 text-title2 text-main" | ||
onClick={handleGuestLogin} | ||
> | ||
게스트 로그인 | ||
<ChevronRight className="w-2 fill-black" /> | ||
</span> | ||
); | ||
} | ||
|
||
export default GuestLogin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { cva } from 'class-variance-authority'; | ||
|
||
import { oauthLogin } from '@/api/auth'; | ||
import GithubIc from '@/assets/icons/github.svg?react'; | ||
import GoogleIc from '@/assets/icons/google.svg?react'; | ||
|
||
const oauthButton = cva('flex w-96 justify-center gap-3 rounded-lg py-4 shadow-normal', { | ||
variants: { | ||
type: { | ||
github: 'bg-black text-white', | ||
google: 'border border-main bg-white text-alt', | ||
}, | ||
}, | ||
defaultVariants: { | ||
type: 'github', | ||
}, | ||
}); | ||
|
||
const OAUTH_LABEL = { | ||
github: 'Github', | ||
google: 'Google', | ||
} as const; | ||
|
||
type OAuthType = keyof typeof OAUTH_LABEL; | ||
|
||
interface OAuthLoginProps { | ||
type: OAuthType; | ||
} | ||
|
||
function OAuthLogin({ type }: OAuthLoginProps) { | ||
const onLoginBtnClick = (type: OAuthType) => { | ||
oauthLogin(type); | ||
}; | ||
|
||
return ( | ||
<button type="button" className={oauthButton({ type })} onClick={() => onLoginBtnClick(type)}> | ||
{type === 'github' ? <GithubIc /> : <GoogleIc />} | ||
<span className="text-head3">{OAUTH_LABEL[type]} 계정으로 로그인</span> | ||
</button> | ||
); | ||
} | ||
|
||
export default OAuthLogin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import TicleCharacterBadge from '@/assets/images/ticle-character-badge.png'; | ||
import TicleLogo from '@/assets/ticle.svg?react'; | ||
|
||
import GuestLogin from './GuestLogin'; | ||
import OAuthLogin from './OAuthLogin'; | ||
|
||
function Auth() { | ||
return ( | ||
<div className="flex h-dvh w-full flex-col items-center justify-center gap-16"> | ||
<div className="flex flex-col items-center gap-6"> | ||
<img src={TicleCharacterBadge} alt="티클 캐릭터" width={150} height={150} /> | ||
<TicleLogo className="fill-primary" width={190} /> | ||
<span className="text-head3 text-alt">작은 지식이 모여 큰 성장이 되는 곳</span> | ||
</div> | ||
<main className="flex flex-col items-center gap-4"> | ||
<OAuthLogin type="github" /> | ||
<OAuthLogin type="google" /> | ||
<GuestLogin /> | ||
</main> | ||
</div> | ||
); | ||
} | ||
|
||
export default Auth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
import { createFileRoute, Link } from '@tanstack/react-router'; | ||
import { createFileRoute } from '@tanstack/react-router'; | ||
|
||
import Auth from '@/components/auth'; | ||
|
||
export const Route = createFileRoute('/auth/oauth')({ | ||
component: RouteComponent, | ||
}); | ||
|
||
function RouteComponent() { | ||
return ( | ||
<div className="flex"> | ||
OAuth 로그인 | ||
<Link to="/auth/login" className="border border-main p-5"> | ||
로컬 로그인 | ||
</Link> | ||
</div> | ||
); | ||
return <Auth />; | ||
} |