fix: 로그인 기능 fix
This commit is contained in:
parent
8aa0a15413
commit
2b075e9d31
@ -11,10 +11,13 @@ export function useAuth() {
|
||||
userId,
|
||||
password,
|
||||
};
|
||||
|
||||
return instance
|
||||
.post(`${API_URL}/user/login`, formData)
|
||||
.then(({ data }) => data['access-token'])
|
||||
.then((accessToken) => {
|
||||
.then(({ data, config }) => {
|
||||
const { 'access-token': accessToken } = data;
|
||||
|
||||
config.headers.Authorization = `${accessToken}`;
|
||||
setToken(accessToken);
|
||||
// TODO: userType 구분 추가
|
||||
setUserType('student');
|
||||
|
@ -12,10 +12,10 @@ const instance = axios.create({
|
||||
});
|
||||
|
||||
instance.interceptors.request.use((config) => {
|
||||
const accessToken = useBoundStore.getState().accessToken;
|
||||
const accessToken = useBoundStore.getState().token;
|
||||
|
||||
if (accessToken) {
|
||||
config.headers.Authorization = `Bearer ${accessToken}`;
|
||||
config.headers.Authorization = `${accessToken}`;
|
||||
}
|
||||
|
||||
return config;
|
||||
@ -34,8 +34,8 @@ instance.interceptors.response.use(
|
||||
return instance.post(REFRESH_API_URL).then((response) => {
|
||||
const { accessToken } = response.data;
|
||||
|
||||
useBoundStore.setState({ accessToken });
|
||||
error.config.headers.Authorization = `Bearer ${accessToken}`;
|
||||
useBoundStore.setState({ token: accessToken });
|
||||
error.config.headers.Authorization = `${accessToken}`;
|
||||
return instance(error.config);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user