Skip to content

Commit

Permalink
feat: implement authorize hook
Browse files Browse the repository at this point in the history
  • Loading branch information
timepresent95 committed Oct 10, 2024
1 parent 81caed7 commit 2a8856d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/business/hooks/useAuth.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { authorizeWithAgent } from '@/business/services/authorizeService';
import { defaultRouteNames } from '@/constants';
import { useSigninWithAgent } from '@/store/queries/useAuthQuery';
import { useAuthStore } from '@/store/stores';
import useNavigationStore from '@/store/stores/navigationStore';
import { AuthAgent } from '@/types';

export default function useAuth() {
const { setIsLogin } = useAuthStore();
const { moveWithFlush } = useNavigationStore();
const { mutate: signinWithAgent } = useSigninWithAgent();

return {
authorize: async (agent: AuthAgent) => {
try {
const agentToken = await authorizeWithAgent(agent);
signinWithAgent({ agent, agentToken });
} catch (error) {
//TODO: OAuth에서 인증이 실패한 경우에 대한 에러 처리가 들어가야 함
}
},
signUpSuccess: () => {
moveWithFlush(defaultRouteNames.HOME);
setIsLogin(true);
Expand Down

0 comments on commit 2a8856d

Please sign in to comment.