Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 이메일 로그인 api 연동 완료 #59

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/modules/payment/view/payment_method_info_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class _PaymentScreenState extends State<PaymentMethodScreen> with WidgetsBinding
text: "확인",
onTap: () async {
if(state == 'REGULAR') {
var result = await OrderApi.postPay(
var result = await OrderApi.setRegularPay(
cardId: controller.cardId.value,
projectId: _projectController.projectId,
amount: controller.selectedDate.value,
Expand Down
3 changes: 3 additions & 0 deletions lib/modules/signIn/controller/login_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ class LoginController extends GetxController {
Rx<TextEditingController> idTextController = TextEditingController().obs;
Rx<TextEditingController> pwTextController = TextEditingController().obs;

RxString userId = ''.obs;
RxString userPw = ''.obs;

//비밀번호 찾을 때 입력하는 이메일
Rx<TextEditingController> findPwTextController = TextEditingController().obs;

Expand Down
16 changes: 11 additions & 5 deletions lib/modules/signIn/view/mail_login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ import '../../../util/components/global_app_bar.dart';
import '../../../util/const/style/global_color.dart';

import 'package:kakao_flutter_sdk/kakao_flutter_sdk.dart'; //카카오 로그인
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'dart:io';

import 'package:match/provider/api/user_auth_api.dart';

import '../../../provider/routes/routes.dart';
import '../controller/login_controller.dart';

class EmailLoginScreen extends GetView<LoginController> {
const EmailLoginScreen({super.key});



@override
Widget build(BuildContext context){
return Scaffold(
Expand All @@ -53,6 +53,7 @@ class EmailLoginScreen extends GetView<LoginController> {
textController : controller.idTextController.value,
onChange: (value) async {
print(">>> 입력한 id: $value");
controller.userId.value = value;
}),
SizedBox(height: 20.h),
Text(
Expand All @@ -64,6 +65,7 @@ class EmailLoginScreen extends GetView<LoginController> {
textController : controller.pwTextController.value,
onChange: (value) async {
print(">>> 입력한 pw: $value");
controller.userPw.value = value;
}),
SizedBox(height: 27.h),
Center(
Expand Down Expand Up @@ -108,8 +110,12 @@ class EmailLoginScreen extends GetView<LoginController> {
child: CommonButton.login(
text: "로그인",
onTap: () async {
//TODO) Get.ofAllNamed() 로 수정 필요
Get.toNamed(Routes.main);
var result = await UserAuthApi.setSignIn(
email: controller.userId.value,
password: controller.userPw.value);
if (result) {
Get.offAllNamed(Routes.main);
}
},
),
),
Expand Down
6 changes: 1 addition & 5 deletions lib/provider/api/order_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,14 @@ class OrderApi {
}

///<h2>4-5API | 정기 결제 등록</h2>
static Future<bool> postPay({
static Future<bool> setRegularPay({
required int cardId,
required int projectId,
required int amount,
required int payDate,
}) async {
try {
Response response = await DioServices().to().post("/order/pay/card/${cardId}/${projectId}",
// queryParameters: {
// "cardId": cardId,
// "projectId": projectId
// },
data: {"amount": amount, "payDate": payDate});

if(!response.data[SUCCESS]) {
Expand Down
38 changes: 38 additions & 0 deletions lib/provider/api/user_auth_api.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:dio/dio.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:match/provider/api/util/global_api_field.dart';
import '../../util/const/style/global_logger.dart';
import 'util/dio_services.dart';

import 'package:match/model/user/user.dart';

class UserAuthApi {

///<h2>1-6API | 유저 로그인</h2>
static Future<bool> setSignIn({
required String email,
required String password,
}) async {
try {
Response response = await DioServices().to().post("/auth/logIn",
data: {"email": email, "password": password});

if(!response.data[SUCCESS]) {
Fluttertoast.showToast(msg: response.data[MSG]);
logger.e(response.data[CODE]);
}

DioServices().tmpToken = response.data[RESULT]["accessToken"];

return response.data[SUCCESS];
} catch(e){
logger.e(e.toString());
return false;
}
}




}