File tree Expand file tree Collapse file tree 5 files changed +43
-15
lines changed
api/src/main/java/org/example/educheck/global/security/config Expand file tree Collapse file tree 5 files changed +43
-15
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
3535 .sessionManagement (session -> session
3636 .sessionCreationPolicy (SessionCreationPolicy .STATELESS ))
3737 .authorizeHttpRequests (auth -> auth
38- .requestMatchers ("/api/auth/login" , "/api/auth/signup" ).permitAll ()
38+ .requestMatchers ("/api/auth/login" , "/api/auth/signup" , "/api/auth/refresh" ).permitAll ()
3939 .anyRequest ().authenticated ()
4040 // TODO: 인증 엔드포인트 수정
4141 )
Original file line number Diff line number Diff line change 1- import React from "react" ;
2- import { RouterProvider } from "react-router-dom" ;
3- import router from "./router" ;
4-
5- import { Provider } from 'react-redux' ;
6- import store from './store/store' ;
1+ import React , { useEffect } from 'react' ;
2+ import { RouterProvider } from 'react-router-dom' ;
3+ import router from './router' ;
4+ import { authApi } from './api/authApi' ;
5+ import { login } from './store/slices/authSlice' ;
6+ import { useDispatch } from 'react-redux' ;
7+ import { setRole } from './store/slices/sideBarItemSlice' ;
78
89export default function App ( ) {
10+ const dispatch = useDispatch ( ) ;
11+
12+ useEffect ( ( ) => {
13+ const fetchRefreshToken = async ( ) => {
14+ try {
15+ const response = await authApi . reissue ( ) ;
16+ const accessToken = response . headers ?. authorization ?? '' ;
17+ dispatch (
18+ login ( {
19+ ...response . data . data ,
20+ accessToken : accessToken ,
21+ } ) ,
22+ setRole ( response . data . data ) ,
23+ ) ;
24+ } catch ( error ) {
25+ console . error ( error ) ;
26+ }
27+ } ;
28+
29+ fetchRefreshToken ( ) ;
30+ } , [ ] ) ;
31+
932 return (
1033 < >
11- < Provider store = { store } >
12- < RouterProvider router = { router } > </ RouterProvider >
13- </ Provider >
34+ < RouterProvider router = { router } > </ RouterProvider >
1435 </ >
1536 ) ;
16- }
37+ }
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export const authApi = {
1919
2020 reissue : async ( ) => {
2121 const response = await apiInstance . post (
22- '/auth/reissue ' ,
22+ '/auth/refresh ' ,
2323 { } ,
2424 {
2525 withCredentials : true ,
Original file line number Diff line number Diff line change @@ -2,9 +2,13 @@ import { StrictMode } from 'react'
22import { createRoot } from 'react-dom/client'
33import App from './App.jsx' ;
44import './css/index.css' ;
5+ import { Provider } from 'react-redux' ;
6+ import store from './store/store.js' ;
57
68createRoot ( document . getElementById ( 'root' ) ) . render (
79 < StrictMode >
8- < App />
10+ < Provider store = { store } >
11+ < App />
12+ </ Provider >
913 </ StrictMode > ,
10- )
14+ ) ;
Original file line number Diff line number Diff line change @@ -19,11 +19,14 @@ export default function Login() {
1919 password : '' ,
2020 } ) ;
2121 const [ isLoginButtonEnable , setIsLoginButtonEnable ] = useState ( false ) ;
22+
23+ const emailRegex = / ^ [ ^ \s @ ] + @ [ ^ \s @ ] + \. [ ^ \s @ ] + $ / ;
2224
2325 const handleInputChange = ( event ) => {
26+ const { name, value } = event . target ;
2427 setInputData ( ( prev ) => ( {
2528 ...prev ,
26- [ event . target . name ] : event . target . value ,
29+ [ name ] : value ,
2730 } ) ) ;
2831 } ;
2932
You can’t perform that action at this time.
0 commit comments