Skip to content

Commit

Permalink
Merge pull request #139 from Garodden/feature/front_login_test
Browse files Browse the repository at this point in the history
Feat: 로그인 테스트 및 수정 개발 진행
  • Loading branch information
lth01 authored May 10, 2024
2 parents 53ec8b9 + 17e30e7 commit ba84a57
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
5 changes: 1 addition & 4 deletions src/front/src/routes/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const Login = () =>{
.catch((err) =>{
alert("로그인에 실패하였습니다.");
})

}

return (
Expand All @@ -54,9 +53,7 @@ const Login = () =>{
<Input id="tBox_pwd" onChange={(ev) => setPwd(ev.target.value)} type="password" placeholder="password"></Input>
</LabelSection>
{/* 버튼은 onClick 콜백 동작 불가 */}
<Button asChild className="bg-[#6866EB] mt-4 w-full hover:bg-violet-600">
<div onClick={doLogin}>로그인</div>
</Button>
<Button onClick={doLogin} className="bg-[#6866EB] mt-4 w-full hover:bg-violet-600">로그인</Button>
<div className="flex justify-center mt-4">
<Link to="/findPassword" className="text-black/65">비밀번호를 잊으셨나요?</Link>
</div>
Expand Down
12 changes: 2 additions & 10 deletions src/front/src/routes/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,8 @@ const Main = () =>{
<div className="w-full text-4xl font-bold text-white">
<h2 className="text-center text-black">Get Started</h2>
<div className="flex justify-center gap-4 mt-4">
<Button className="bg-[#6866EB] w-48 hover:bg-violet-600">
<div onClick={doLogin}>
Login
</div>
</Button>
<Button className="bg-[#6866EB] w-48 hover:bg-violet-600">
<div onClick={goSignup}>
Signup
</div>
</Button>
<Button onClick={doLogin }className="bg-[#6866EB] w-48 hover:bg-violet-600">Login</Button>
<Button onClick={goSignup} className="bg-[#6866EB] w-48 hover:bg-violet-600">Signup</Button>
</div>
</div>
</section>
Expand Down
10 changes: 5 additions & 5 deletions src/front/src/utils/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ instance.interceptors.request.use((config) =>{
const refreshToken = getRefreshToken();

if(accessToken){
config.headers['Authorization'] = `Bearer ${accessToken}`
config.headers['Authorization'] = accessToken;
}
if(refreshToken){
config.headers['Refresh-Token'] = refreshToken;
Expand Down Expand Up @@ -103,10 +103,10 @@ export const signup = async (signupReqParam) =>{
export const login = async (loginReqParam) =>{
const loginURL = URL + "/login";
return OneinkedPost(loginURL, loginReqParam)
.then((response) => response.data)
.then(json =>{
setAccessToken(json.accessToken);
setRefreshToken(json.refreshToken);
.then((response) => {
setAccessToken(response.headers['authorization']);
setRefreshToken(response.headers['refresh-token']);
return response.data;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti
.addFilterBefore(jwtRefreshTokenFilter, UsernamePasswordAuthenticationFilter.class) // JwtAuthenticationFilter 적용
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); // JwtRefreshTokenFilter 적용

/*
httpSecurity.cors(httpSecurityCorsConfigurer -> {
httpSecurityCorsConfigurer.configurationSource(configurationSource());
});
*/

return httpSecurity.build();
}
Expand All @@ -68,11 +66,14 @@ public CorsConfigurationSource configurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOriginPatterns(Arrays.asList("*"));
configuration.setAllowedMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE"));
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Cache-Control", "Content-Type"));
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Cache-Control", "Content-Type", "Refresh-Token"));
configuration.setAllowCredentials(true);

configuration.setExposedHeaders(Arrays.asList("Access-Control-Allow-Headers", "Authorization, x-xsrf-token, Access-Control-Allow-Headers, Origin, Accept, X-Requested-With, " +
"Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers", "Refresh-Token"));

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}

}

0 comments on commit ba84a57

Please sign in to comment.