Skip to content

Commit

Permalink
fix. 로그인 관련 에러 수정 #77
Browse files Browse the repository at this point in the history
  • Loading branch information
JoGeumJu committed Apr 4, 2024
1 parent 603fd10 commit eb697d3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/controllers/user_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:image_picker/image_picker.dart';
import 'package:meonghae_front/api/dio.dart';
import 'package:meonghae_front/config/app_routes.dart';
import 'package:meonghae_front/login/token.dart';
import 'package:meonghae_front/models/login_model.dart';
import 'package:meonghae_front/models/user_info_model.dart';
import 'package:dio/dio.dart' as dio;
import 'package:meonghae_front/widgets/common/custom_warning_modal_widget.dart';
Expand Down Expand Up @@ -182,7 +183,7 @@ class UserController extends GetxController {
() => SendAPI.put(
url: "/user-service/withdrawal",
successFunc: (data) {
Get.offAllNamed(AppRoutes.login);
LoginModel.logout();
SnackBarWidget.show(SnackBarType.check, '회원탈퇴에 성공했어요');
},
errorMsg: "회원탈퇴에 실패하였어요"));
Expand Down
32 changes: 19 additions & 13 deletions lib/models/login_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,25 @@ class LoginModel {
.getToken(vapidKey: dotenv.env['FCM_VAPID_KEY']);
try {
user = await UserApi.instance.me();
final response = await dio.get('/user-service/login',
queryParameters: {'email': user!.kakaoAccount!.email},
options: Options(
headers: {'androidId': mobileId, 'FCMToken': fcmToken}));
if (response.data['responseCode'] == "200_OK") {
await saveAccessToken(response.headers['authorization']![0]);
await saveRefreshToken(response.headers['refreshtoken']![0]);
await Get.offNamed(AppRoutes.introVideo);
} else if (response.data['responseCode'] == "201_CREATED") {
Get.find<UserController>().setRegisterEmail(response.data['email']);
await Get.offNamed(AppRoutes.select);
if (user!.kakaoAccount?.email == "" ||
user!.kakaoAccount?.email == null) {
SnackBarWidget.show(
SnackBarType.error, "이메일 없다는디요: ${user!.kakaoAccount?.email}");
} else {
SnackBarWidget(SnackBarType.error, '허가되지 않은 게정이에요');
final response = await dio.get('/user-service/login',
queryParameters: {'email': user!.kakaoAccount!.email},
options: Options(
headers: {'androidId': mobileId, 'FCMToken': fcmToken}));
if (response.data['responseCode'] == "200_OK") {
await saveAccessToken(response.headers['authorization']![0]);
await saveRefreshToken(response.headers['refreshtoken']![0]);
await Get.offNamed(AppRoutes.introVideo);
} else if (response.data['responseCode'] == "201_CREATED") {
Get.find<UserController>().setRegisterEmail(response.data['email']);
await Get.offNamed(AppRoutes.select);
} else {
SnackBarWidget(SnackBarType.error, '허가되지 않은 게정이에요');
}
}
} on DioException catch (error) {
if (error.response?.data['errorCode'] == 'Already Withdrawal') {
Expand Down Expand Up @@ -146,7 +152,7 @@ class LoginModel {
dio.close();
}
} else {
Get.offNamed(AppRoutes.login);
logout();
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: meonghae_front
description: 애완동물 스케줄 관리를 위한 어플리케이션
publish_to:

version: 2.0.3+10
version: 2.0.4+11

environment:
sdk: ">=3.0.0-322.0.dev <4.0.0"
Expand Down

0 comments on commit eb697d3

Please sign in to comment.