Skip to content

Commit

Permalink
#78 feat: set users login, signup api (#79)
Browse files Browse the repository at this point in the history
* #77 feat: add ComponentsTest page at Home

* #78 feat: test users/signup

* #78 feat: set domain url
  • Loading branch information
eujin-shin authored Jun 22, 2024
1 parent 98dd23c commit c3298cc
Show file tree
Hide file tree
Showing 8 changed files with 661 additions and 464 deletions.
3 changes: 3 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import SignIn from './src/components/Auth/SignIn';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { BottomBarProvider, useBottomBar } from './contexts/BottomBarContext';
import { LoginProvider } from './src/common/Context';
import Reformer from './src/components/Auth/Reformer/Reformer';

export type StackProps = {
Home: undefined;
Signin: undefined;
ReformProfile: undefined;
};

const Stack = createNativeStackNavigator<StackProps>();
Expand All @@ -49,6 +51,7 @@ function App(): React.JSX.Element {
})}>
<Stack.Screen name="Home" component={HomeTab} />
<Stack.Screen name="Signin" component={SignIn} />
<Stack.Screen name="ReformProfile" component={Reformer} />
</Stack.Navigator>
</NavigationContainer>
</LoginProvider>
Expand Down
10 changes: 7 additions & 3 deletions src/common/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export default function Request() {
const accessToken = await getAccessToken();
const refreshToken = await getRefreshToken();

const url = UPCY_API_URL + path;
// upcy temp api url: http://52.78.43.6:8000/
// upcy domain: http://upcy.co.kr:8000/
// https 요청 문제로 도메인 연결 보류

const url = 'http://52.78.43.6:8000/' + path;

let headerValue;

Expand All @@ -37,7 +41,7 @@ export default function Request() {
// 백엔드와 통신 자체가 실패(ERR_CONNECTION_REFUSED)
console.log(err);
Alert.alert('ERR_CONNECTION_REFUSED' + UPCY_API_URL);
console.warn(UPCY_API_URL);
console.warn(url);
throw err;
} else if (err.response.status === 401) {
// access 토큰이 만료된 경우 또는 로그인이 필요한 기능의 경우
Expand All @@ -47,7 +51,7 @@ export default function Request() {
// refresh 토큰을 통해 access 토큰 재발급
try {
const response = await axios.post(
UPCY_API_URL + '/users/token/refresh/',
UPCY_API_URL + 'users/token/refresh/',
{
refresh: refreshToken,
},
Expand Down
5 changes: 4 additions & 1 deletion src/components/Auth/BasicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ export default function BasicForm({ navigation, route }: FormProps) {
area: form.region,
};
const response = await request.post(`users/signup/`, params, {});
if (response?.status === 200) {
if (response?.status === 201) {
console.log(params);
setSplash(true);
setTimeout(() => {
navigation.getParent()?.navigate('Home');
}, 3000);
} else if (response?.status === 500) {
console.log(response);
Alert.alert('이미 가입된 이메일입니다.');
} else {
console.log(response);
Alert.alert('가입에 실패했습니다.');
Expand Down
Loading

0 comments on commit c3298cc

Please sign in to comment.