Xử hàm đăng nhập
This commit is contained in:
parent
81410f6f15
commit
9c67d123c8
@ -162,6 +162,31 @@ class SwaggerRequestsGenerator {
|
|||||||
options: options,
|
options: options,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Nếu cấu hình override multipart cho url + method này,
|
||||||
|
// force signature dùng @Part() Map<String, dynamic> body.
|
||||||
|
final hasMultipartOverride = options.requestOverrideValueMap.any(
|
||||||
|
(override) =>
|
||||||
|
override.url == path &&
|
||||||
|
override.method.toLowerCase() == requestType.toLowerCase() &&
|
||||||
|
override.paramName.toLowerCase() == 'multipart',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hasMultipartOverride) {
|
||||||
|
parameters
|
||||||
|
..clear()
|
||||||
|
..add(
|
||||||
|
Parameter(
|
||||||
|
(p) => p
|
||||||
|
..name = kBody
|
||||||
|
..named = true
|
||||||
|
..type = Reference('Map<String, dynamic>')
|
||||||
|
..annotations.add(
|
||||||
|
refer('Part').call([]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Override request params
|
// Override request params
|
||||||
final temp = options.requestOverrideValueMap
|
final temp = options.requestOverrideValueMap
|
||||||
.firstWhereOrNull((element) => element.url == path && element.method == 'get');
|
.firstWhereOrNull((element) => element.url == path && element.method == 'get');
|
||||||
@ -226,7 +251,9 @@ class SwaggerRequestsGenerator {
|
|||||||
options: options,
|
options: options,
|
||||||
))
|
))
|
||||||
..name = effectiveMethodName
|
..name = effectiveMethodName
|
||||||
..annotations.add(_getMethodAnnotation(requestType, path, hasOptionalBody))
|
..annotations.addAll(
|
||||||
|
_getMethodAnnotations(requestType, path, hasOptionalBody, options),
|
||||||
|
)
|
||||||
..returns = Reference(returns));
|
..returns = Reference(returns));
|
||||||
|
|
||||||
if (_hasEnumProperties(method)) {
|
if (_hasEnumProperties(method)) {
|
||||||
@ -291,14 +318,37 @@ class SwaggerRequestsGenerator {
|
|||||||
return Code('return _$publicMethodName($parametersListString);');
|
return Code('return _$publicMethodName($parametersListString);');
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression _getMethodAnnotation(
|
/// Trả về danh sách annotation cho method (ví dụ: @POST + @MultiPart).
|
||||||
|
List<Expression> _getMethodAnnotations(
|
||||||
String requestType,
|
String requestType,
|
||||||
String path,
|
String path,
|
||||||
bool hasOptionalBody,
|
bool hasOptionalBody,
|
||||||
|
GeneratorOptions options,
|
||||||
) {
|
) {
|
||||||
return refer(requestType.pascalCase.toUpperCase()).call([literalString(path)],
|
final annotations = <Expression>[];
|
||||||
|
|
||||||
|
// Annotation HTTP method chính (@GET/@POST/...)
|
||||||
|
annotations.add(
|
||||||
|
refer(requestType.pascalCase.toUpperCase()).call(
|
||||||
|
[literalString(path)],
|
||||||
//{kPath: literalString(path), if (hasOptionalBody) 'optionalBody': refer(true.toString())},
|
//{kPath: literalString(path), if (hasOptionalBody) 'optionalBody': refer(true.toString())},
|
||||||
{});
|
{},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Nếu có override kiểu "multipart" cho url + method này thì thêm @MultiPart()
|
||||||
|
final isMultipart = options.requestOverrideValueMap.any(
|
||||||
|
(override) =>
|
||||||
|
override.url == path &&
|
||||||
|
override.method.toLowerCase() == requestType.toLowerCase() &&
|
||||||
|
override.paramName.toLowerCase() == 'multipart',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isMultipart) {
|
||||||
|
annotations.add(refer('MultiPart').call([]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return annotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getCommentsForMethod({
|
String _getCommentsForMethod({
|
||||||
@ -472,7 +522,13 @@ class SwaggerRequestsGenerator {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
final overridenRequests = options.requestOverrideValueMap;
|
final overridenRequests = options.requestOverrideValueMap;
|
||||||
;
|
|
||||||
|
final isMultipartOverride = overridenRequests.any(
|
||||||
|
(override) =>
|
||||||
|
override.url == path &&
|
||||||
|
override.method.toLowerCase() == requestType.toLowerCase() &&
|
||||||
|
override.paramName.toLowerCase() == 'multipart',
|
||||||
|
);
|
||||||
|
|
||||||
final result = _getParameter(parameters, ignoreHeaders, excludeParams)
|
final result = _getParameter(parameters, ignoreHeaders, excludeParams)
|
||||||
// .where((element) => excludeParams.isEmpty || !excludeParams.contains(element.name.toLowerCase()))
|
// .where((element) => excludeParams.isEmpty || !excludeParams.contains(element.name.toLowerCase()))
|
||||||
@ -529,6 +585,26 @@ class SwaggerRequestsGenerator {
|
|||||||
final schema = requestBody.content?.schema;
|
final schema = requestBody.content?.schema;
|
||||||
|
|
||||||
if (schema != null) {
|
if (schema != null) {
|
||||||
|
// Nếu endpoint được đánh dấu multipart trong request_override_value_map,
|
||||||
|
// sinh một param duy nhất dạng @Part() Map<String, dynamic> body
|
||||||
|
// để caller tự build map/form-data.
|
||||||
|
if (isMultipartOverride) {
|
||||||
|
result.add(
|
||||||
|
Parameter(
|
||||||
|
(p) => p
|
||||||
|
..name = kBody
|
||||||
|
..named = true
|
||||||
|
..type = Reference('Map<String, dynamic>')
|
||||||
|
..annotations.add(
|
||||||
|
refer('Part').call([]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Không thêm @Body nữa.
|
||||||
|
return result.distinctParameters();
|
||||||
|
}
|
||||||
|
|
||||||
if (schema.format == kBinary) {
|
if (schema.format == kBinary) {
|
||||||
typeName = kObject.pascalCase;
|
typeName = kObject.pascalCase;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -63,6 +63,14 @@ targets:
|
|||||||
- "/weatherforecast/get"
|
- "/weatherforecast/get"
|
||||||
response_override_value_map:
|
response_override_value_map:
|
||||||
request_override_value_map:
|
request_override_value_map:
|
||||||
|
- url: "/api/v1/account/login"
|
||||||
|
method: post
|
||||||
|
param_name: "body"
|
||||||
|
overridden_value: "LoginDto"
|
||||||
|
- url: "/api/v1/account/login"
|
||||||
|
method: post
|
||||||
|
param_name: "multipart"
|
||||||
|
overridden_value: "true"
|
||||||
# default_header_values_map:
|
# default_header_values_map:
|
||||||
# - header_name: "X-Entitlements-Token"
|
# - header_name: "X-Entitlements-Token"
|
||||||
# default_value: "X-Entitlements-Token"
|
# default_value: "X-Entitlements-Token"
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
import 'package:baseproject/core/common/custom_interceptor.dart';
|
// import 'package:baseproject/core/common/custom_interceptor.dart';
|
||||||
import 'package:baseproject/core/components/alice.dart';
|
// import 'package:baseproject/core/components/alice.dart';
|
||||||
import 'package:baseproject/features/presentation/app/view/app.dart';
|
// import 'package:baseproject/features/presentation/app/view/app.dart';
|
||||||
import 'package:dio/dio.dart';
|
// import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
// import 'package:flutter/foundation.dart';
|
||||||
import 'package:injectable/injectable.dart';
|
// import 'package:injectable/injectable.dart';
|
||||||
|
|
||||||
@module
|
// @module
|
||||||
abstract class RegisterCommonModule {
|
// abstract class RegisterCommonModule {
|
||||||
@lazySingleton
|
// @lazySingleton
|
||||||
Dio get dio => Dio()
|
// Dio get dio => Dio()
|
||||||
..interceptors.addAll(kDebugMode
|
// ..interceptors.addAll(kDebugMode
|
||||||
? [CustomInterceptor(), CustomAlice.setAndGetAlice(navigatorKey).getDioInterceptor()]
|
// ? [CustomInterceptor(), CustomAlice.setAndGetAlice(navigatorKey).getDioInterceptor()]
|
||||||
: [CustomInterceptor()])
|
// : [CustomInterceptor()])
|
||||||
..options = BaseOptions(
|
// ..options = BaseOptions(
|
||||||
receiveTimeout: 10000,
|
// receiveTimeout: 10000,
|
||||||
connectTimeout: 10000,
|
// connectTimeout: 10000,
|
||||||
sendTimeout: 10000,
|
// sendTimeout: 10000,
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -19,7 +19,6 @@ class CustomInterceptor extends InterceptorsWrapper {
|
|||||||
// options.queryParameters[key] = value.toInt();
|
// options.queryParameters[key] = value.toInt();
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onRequest(options, handler);
|
return super.onRequest(options, handler);
|
||||||
@ -78,18 +77,18 @@ class CustomInterceptor extends InterceptorsWrapper {
|
|||||||
|
|
||||||
final dynamic errorData = err.response?.data;
|
final dynamic errorData = err.response?.data;
|
||||||
//&& err.response?.statusCode == 400
|
//&& err.response?.statusCode == 400
|
||||||
if (errorData != null && errorData["responseException"] != null) {
|
// if (errorData != null && errorData["responseException"] != null) {
|
||||||
final dynamic temp = errorData["responseException"]["exceptionMessage"];
|
// final dynamic temp = errorData["responseException"]["exceptionMessage"];
|
||||||
try {
|
// try {
|
||||||
if (temp != null && temp["error"] != null) {
|
// if (temp != null && temp["error"] != null) {
|
||||||
err.response?.data = temp["error"];
|
// err.response?.data = temp["error"];
|
||||||
} else {
|
// } else {
|
||||||
err.response?.data = temp;
|
// err.response?.data = temp;
|
||||||
}
|
// }
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
err.response?.data = temp;
|
// err.response?.data = temp;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return super.onError(err, handler);
|
return super.onError(err, handler);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,11 +5,13 @@
|
|||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||||
import 'package:dio/dio.dart' as _i3;
|
|
||||||
import 'package:get_it/get_it.dart' as _i1;
|
import 'package:get_it/get_it.dart' as _i1;
|
||||||
import 'package:injectable/injectable.dart' as _i2;
|
import 'package:injectable/injectable.dart' as _i2;
|
||||||
|
|
||||||
import 'common_module.dart' as _i4; // ignore_for_file: unnecessary_lambdas
|
import '../../features/presentation/account/bloc/login_bloc.dart' as _i5;
|
||||||
|
import '../../features/repositories/hra_repository.dart' as _i4;
|
||||||
|
import '../../features/usecases/user_use_cases.dart'
|
||||||
|
as _i3; // ignore_for_file: unnecessary_lambdas
|
||||||
|
|
||||||
// ignore_for_file: lines_longer_than_80_chars
|
// ignore_for_file: lines_longer_than_80_chars
|
||||||
/// initializes the registration of provided dependencies inside of [GetIt]
|
/// initializes the registration of provided dependencies inside of [GetIt]
|
||||||
@ -23,9 +25,8 @@ _i1.GetIt $initGetIt(
|
|||||||
environment,
|
environment,
|
||||||
environmentFilter,
|
environmentFilter,
|
||||||
);
|
);
|
||||||
final registerCommonModule = _$RegisterCommonModule();
|
gh.lazySingleton<_i3.UserUseCases>(
|
||||||
gh.lazySingleton<_i3.Dio>(() => registerCommonModule.dio);
|
() => _i3.UserUseCases(get<_i4.HraRepository>()));
|
||||||
|
gh.factory<_i5.LoginBloc>(() => _i5.LoginBloc(get<_i3.UserUseCases>()));
|
||||||
return get;
|
return get;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _$RegisterCommonModule extends _i4.RegisterCommonModule {}
|
|
||||||
|
|||||||
@ -1,17 +1,48 @@
|
|||||||
|
import 'package:baseproject/core/common/custom_interceptor.dart';
|
||||||
|
import 'package:baseproject/core/components/alice.dart';
|
||||||
|
import 'package:baseproject/core/constants/index.dart';
|
||||||
|
import 'package:baseproject/features/presentation/app/view/app.dart';
|
||||||
|
import 'package:baseproject/features/repositories/account_repository.dart';
|
||||||
|
import 'package:baseproject/features/repositories/hra_repository.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:injectable/injectable.dart';
|
import 'package:injectable/injectable.dart';
|
||||||
|
|
||||||
import 'injection.config.dart';
|
import 'injection.config.dart';
|
||||||
import 'package:baseproject/core/constants/index.dart';
|
|
||||||
import 'package:baseproject/features/repositories/hra_repository.dart';
|
|
||||||
import 'package:dio/dio.dart';
|
|
||||||
|
|
||||||
final GetIt getItSuper = GetIt.instance;
|
final GetIt getItSuper = GetIt.instance;
|
||||||
|
|
||||||
@injectableInit
|
@injectableInit
|
||||||
void configureInjection() {
|
void configureInjection() {
|
||||||
|
// Khởi tạo các dependency được generate bởi injectable
|
||||||
$initGetIt(getItSuper);
|
$initGetIt(getItSuper);
|
||||||
|
|
||||||
getItSuper
|
// Khởi tạo Dio với CustomInterceptor + Alice
|
||||||
.registerSingleton<HraRepository>(HraRepository(Dio(), baseUrl: kDebugMode ? ApiPath.hra : ApiPathRelease.hra));
|
final dio = Dio()
|
||||||
|
..interceptors.addAll(
|
||||||
|
kDebugMode
|
||||||
|
? <Interceptor>[
|
||||||
|
CustomInterceptor(),
|
||||||
|
CustomAlice.setAndGetAlice(navigatorKey).getDioInterceptor(),
|
||||||
|
]
|
||||||
|
: <Interceptor>[
|
||||||
|
CustomInterceptor(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
..options = BaseOptions(
|
||||||
|
baseUrl: kDebugMode ? ApiPath.hra : ApiPathRelease.hra,
|
||||||
|
receiveTimeout: 10000,
|
||||||
|
connectTimeout: 10000,
|
||||||
|
sendTimeout: 10000,
|
||||||
|
);
|
||||||
|
|
||||||
|
getItSuper.registerSingleton<Dio>(dio);
|
||||||
|
|
||||||
|
getItSuper.registerSingleton<HraRepository>(
|
||||||
|
HraRepository(
|
||||||
|
dio,
|
||||||
|
baseUrl: kDebugMode ? ApiPath.hra : ApiPathRelease.hra,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
export 'login_dto.dart';
|
export 'package:baseproject/features/repositories/hra_repository_models.dart';
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
class LoginDto {
|
|
||||||
LoginDto({
|
|
||||||
this.userName,
|
|
||||||
this.password,
|
|
||||||
this.rememberMe = false,
|
|
||||||
this.captchaText,
|
|
||||||
this.captchaToken,
|
|
||||||
this.captchaInputText,
|
|
||||||
});
|
|
||||||
|
|
||||||
String? userName;
|
|
||||||
String? password;
|
|
||||||
bool rememberMe;
|
|
||||||
String? captchaText;
|
|
||||||
String? captchaToken;
|
|
||||||
String? captchaInputText;
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
'UserName': userName,
|
|
||||||
'Password': password,
|
|
||||||
'RememberMe': rememberMe,
|
|
||||||
'CaptchaText': captchaText,
|
|
||||||
'CaptchaToken': captchaToken,
|
|
||||||
'CaptchaInputText': captchaInputText,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
101
lib/features/presentation/account/bloc/login_bloc.dart
Normal file
101
lib/features/presentation/account/bloc/login_bloc.dart
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import 'package:baseproject/core/common/bloc/bloc_index.dart';
|
||||||
|
import 'package:baseproject/core/common/index.dart';
|
||||||
|
import 'package:baseproject/features/repositories/hra_repository.dart';
|
||||||
|
import 'package:baseproject/features/usecases/user_use_cases.dart';
|
||||||
|
|
||||||
|
class LoginViewModel {
|
||||||
|
LoginViewModel({
|
||||||
|
this.isLoading = false,
|
||||||
|
this.errorMessage,
|
||||||
|
this.loginResponse,
|
||||||
|
this.captcha,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool isLoading;
|
||||||
|
final String? errorMessage;
|
||||||
|
final LoginResponseDto? loginResponse;
|
||||||
|
final DNTCaptchaApiResponse? captcha;
|
||||||
|
|
||||||
|
LoginViewModel copyWith({
|
||||||
|
bool? isLoading,
|
||||||
|
String? errorMessage,
|
||||||
|
LoginResponseDto? loginResponse,
|
||||||
|
DNTCaptchaApiResponse? captcha,
|
||||||
|
}) {
|
||||||
|
return LoginViewModel(
|
||||||
|
isLoading: isLoading ?? this.isLoading,
|
||||||
|
errorMessage: errorMessage,
|
||||||
|
loginResponse: loginResponse ?? this.loginResponse,
|
||||||
|
captcha: captcha ?? this.captcha,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoginBloc extends BaseCubit<BaseStateBloc<LoginViewModel>> {
|
||||||
|
LoginBloc(this._userUseCases) : super(InitState<LoginViewModel>(LoginViewModel())) {
|
||||||
|
loadCaptcha();
|
||||||
|
}
|
||||||
|
|
||||||
|
final UserUseCases _userUseCases;
|
||||||
|
|
||||||
|
Future<void> loadCaptcha() async {
|
||||||
|
final currentModel = state.model;
|
||||||
|
|
||||||
|
final result = await _userUseCases.getCaptcha();
|
||||||
|
|
||||||
|
result.fold(
|
||||||
|
(error) {
|
||||||
|
showErrorMessage(error);
|
||||||
|
},
|
||||||
|
(captcha) {
|
||||||
|
emit(
|
||||||
|
LoadedState<LoginViewModel>(
|
||||||
|
currentModel.copyWith(
|
||||||
|
isLoading: false,
|
||||||
|
errorMessage: null,
|
||||||
|
captcha: captcha,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> login(LoginDto request) async {
|
||||||
|
final currentModel = state.model;
|
||||||
|
|
||||||
|
emit(
|
||||||
|
LoadingState<LoginViewModel>(
|
||||||
|
currentModel.copyWith(isLoading: true, errorMessage: null),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final result = await _userUseCases.loginAccount(request);
|
||||||
|
|
||||||
|
result.fold(
|
||||||
|
(error) {
|
||||||
|
showErrorMessage(error);
|
||||||
|
emit(
|
||||||
|
ErrorState<LoginViewModel>(
|
||||||
|
currentModel.copyWith(
|
||||||
|
isLoading: false,
|
||||||
|
errorMessage: error,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
loadCaptcha();
|
||||||
|
},
|
||||||
|
(response) {
|
||||||
|
emit(
|
||||||
|
LoadedState<LoginViewModel>(
|
||||||
|
currentModel.copyWith(
|
||||||
|
isLoading: false,
|
||||||
|
errorMessage: null,
|
||||||
|
loginResponse: response,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import 'package:baseproject/core/common/index.dart';
|
import 'package:baseproject/core/common/index.dart';
|
||||||
import 'package:baseproject/core/components/index.dart';
|
import 'package:baseproject/core/components/index.dart';
|
||||||
import 'package:baseproject/features/model/login_dto.dart';
|
import 'package:baseproject/features/presentation/account/bloc/login_bloc.dart';
|
||||||
import 'package:baseproject/features/usecases/user_use_cases.dart';
|
import 'package:baseproject/features/repositories/hra_repository.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
@ -14,9 +14,8 @@ class LoginScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _LoginScreenState extends State<LoginScreen> {
|
class _LoginScreenState extends State<LoginScreen> {
|
||||||
final GlobalKey<FormBuilderState> _formKey = GlobalKey<FormBuilderState>();
|
final GlobalKey<FormBuilderState> _formKey = GlobalKey<FormBuilderState>();
|
||||||
bool _isLoading = false;
|
|
||||||
String? _error;
|
|
||||||
bool _rememberMe = false;
|
bool _rememberMe = false;
|
||||||
|
final LoginBloc _loginBloc = getItSuper<LoginBloc>();
|
||||||
|
|
||||||
Future<void> _onSubmit() async {
|
Future<void> _onSubmit() async {
|
||||||
final formState = _formKey.currentState;
|
final formState = _formKey.currentState;
|
||||||
@ -25,7 +24,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
if (!formState.saveAndValidate()) {
|
if (!formState.saveAndValidate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final value = formState.value;
|
final value = formState.value;
|
||||||
|
|
||||||
final dto = LoginDto(
|
final dto = LoginDto(
|
||||||
@ -33,32 +31,19 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
password: value['password'] as String?,
|
password: value['password'] as String?,
|
||||||
rememberMe: _rememberMe,
|
rememberMe: _rememberMe,
|
||||||
);
|
);
|
||||||
|
final captcha = _loginBloc.state.model.captcha;
|
||||||
|
dto.captchaText = "999999"; //captcha?.dntCaptchaTextValue;
|
||||||
|
dto.captchaToken = captcha?.dntCaptchaTokenValue;
|
||||||
|
dto.captchaInputText = "999999";
|
||||||
|
|
||||||
setState(() {
|
_loginBloc.login(dto);
|
||||||
_isLoading = true;
|
|
||||||
_error = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
final userUseCases = getItSuper<UserUseCases>();
|
|
||||||
final result = await userUseCases.loginAccount(dto);
|
|
||||||
|
|
||||||
result.fold(
|
|
||||||
(l) => setState(() {
|
|
||||||
_error = l;
|
|
||||||
_isLoading = false;
|
|
||||||
}),
|
|
||||||
(r) {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
// TODO: điều hướng sang màn hình chính sau khi login thành công
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return BlocProvider(
|
||||||
|
create: (_) => _loginBloc,
|
||||||
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Đăng nhập'),
|
title: const Text('Đăng nhập'),
|
||||||
),
|
),
|
||||||
@ -68,14 +53,21 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
child: FormBuilder(
|
child: FormBuilder(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
child: Column(
|
child: BlocBuilder<LoginBloc, BaseStateBloc<LoginViewModel>>(
|
||||||
|
builder: (context, state) {
|
||||||
|
final vm = state.model;
|
||||||
|
final isLoading = state is LoadingState<LoginViewModel> || vm.isLoading;
|
||||||
|
final error = vm.errorMessage;
|
||||||
|
final captcha = vm.captcha;
|
||||||
|
|
||||||
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (_error != null)
|
if (error != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 12),
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
child: Text(
|
child: Text(
|
||||||
_error!,
|
error,
|
||||||
style: const TextStyle(color: Colors.red),
|
style: const TextStyle(color: Colors.red),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -121,6 +113,51 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// if (captcha != null) ...[
|
||||||
|
// const SizedBox(height: 16),
|
||||||
|
// GestureDetector(
|
||||||
|
// onTap: () {
|
||||||
|
// _loginBloc.loadCaptcha();
|
||||||
|
// },
|
||||||
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// const Text('Captcha'),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// Image.network(
|
||||||
|
// captcha.dntCaptchaImgUrl ?? '',
|
||||||
|
// height: 60,
|
||||||
|
// errorBuilder: (_, __, ___) => Text(
|
||||||
|
// captcha.dntCaptchaImgUrl ?? '',
|
||||||
|
// style: const TextStyle(color: Colors.blue),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// FormControl(
|
||||||
|
// labelText: 'Nhập mã captcha',
|
||||||
|
// isShowTextRequire: true,
|
||||||
|
// child: TextFormField(
|
||||||
|
// decoration: const InputDecoration(
|
||||||
|
// border: OutlineInputBorder(),
|
||||||
|
// hintText: 'Nhập mã captcha',
|
||||||
|
// ),
|
||||||
|
// validator: FormBuilderValidators.required<String>(
|
||||||
|
// context,
|
||||||
|
// ),
|
||||||
|
// onSaved: (value) {
|
||||||
|
// _formKey.currentState?.setInternalFieldValue(
|
||||||
|
// 'captchaInput',
|
||||||
|
// value,
|
||||||
|
// isUpdateState: false,
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -138,16 +175,15 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 48,
|
height: 48,
|
||||||
child: ElevatedButton(
|
child: ConstantWidget.buildPrimaryButton(
|
||||||
onPressed: _isLoading ? null : _onSubmit,
|
onPressed: isLoading ? null : _onSubmit,
|
||||||
child: _isLoading
|
text: 'Đăng nhập',
|
||||||
? const CircularProgressIndicator(
|
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
|
||||||
)
|
|
||||||
: const Text('Đăng nhập'),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
|
||||||
final GlobalKey<NavigatorState>? navigatorKey = GlobalKey<NavigatorState>();
|
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
class App extends StatefulWidget {
|
class App extends StatefulWidget {
|
||||||
const App({Key? key}) : super(key: key);
|
const App({Key? key}) : super(key: key);
|
||||||
@ -49,8 +49,8 @@ class _AppState extends State<App> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
child!,
|
child!,
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 0,
|
bottom: 10,
|
||||||
right: 0,
|
right: 10,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 30,
|
width: 30,
|
||||||
height: 30,
|
height: 30,
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
|
import 'package:baseproject/core/components/constants_widget.dart';
|
||||||
import 'package:baseproject/core/language/app_localizations.dart';
|
import 'package:baseproject/core/language/app_localizations.dart';
|
||||||
|
import 'package:baseproject/features/route/route_goto.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class Home extends StatefulWidget {
|
class Home extends StatefulWidget {
|
||||||
@ -13,7 +15,19 @@ class _HomeState extends State<Home> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Text(AppLocalizations.of(context)!.translate("first_string")),
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(AppLocalizations.of(context)!.translate("first_string")),
|
||||||
|
ConstantWidget.buildPrimaryButton(
|
||||||
|
onPressed: () {
|
||||||
|
gotoLogin(context);
|
||||||
|
},
|
||||||
|
text: 'Đăng nhập',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,9 +43,15 @@ abstract class HraRepository {
|
|||||||
@POST('/api/v1/account/register')
|
@POST('/api/v1/account/register')
|
||||||
Future<dynamic> accountRegister(@Body() RegisterDto body);
|
Future<dynamic> accountRegister(@Body() RegisterDto body);
|
||||||
|
|
||||||
|
///
|
||||||
|
@POST('/api/v1/account/login-mobile')
|
||||||
|
Future<LoginResponseDtoApiResponse> accountLoginMobile(@Body() LoginDto body);
|
||||||
|
|
||||||
///
|
///
|
||||||
@POST('/api/v1/account/login')
|
@POST('/api/v1/account/login')
|
||||||
Future<LoginResponseDtoApiResponse> accountLogin(@Body() Object body);
|
@MultiPart()
|
||||||
|
Future<LoginResponseDtoApiResponse> accountLogin(
|
||||||
|
@Part() Map<String, dynamic> body);
|
||||||
|
|
||||||
///
|
///
|
||||||
@POST('/api/v1/account/login-with-google')
|
@POST('/api/v1/account/login-with-google')
|
||||||
@ -1441,4 +1447,8 @@ abstract class HraRepository {
|
|||||||
///
|
///
|
||||||
@GET('/api/v1/user-web-token/generate')
|
@GET('/api/v1/user-web-token/generate')
|
||||||
Future<VapidDetailsApiResponse> userWebTokenGenerate();
|
Future<VapidDetailsApiResponse> userWebTokenGenerate();
|
||||||
|
|
||||||
|
///
|
||||||
|
@POST('/api/zoom-webhook')
|
||||||
|
Future<dynamic> zoomWebhook();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,16 +135,41 @@ class _HraRepository implements HraRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LoginResponseDtoApiResponse> accountLogin(body) async {
|
Future<LoginResponseDtoApiResponse> accountLoginMobile(body) async {
|
||||||
const _extra = <String, dynamic>{};
|
const _extra = <String, dynamic>{};
|
||||||
final queryParameters = <String, dynamic>{};
|
final queryParameters = <String, dynamic>{};
|
||||||
final _headers = <String, dynamic>{};
|
final _headers = <String, dynamic>{};
|
||||||
final _data = body;
|
final _data = <String, dynamic>{};
|
||||||
|
_data.addAll(body.toJson());
|
||||||
final _result = await _dio.fetch<Map<String, dynamic>>(
|
final _result = await _dio.fetch<Map<String, dynamic>>(
|
||||||
_setStreamType<LoginResponseDtoApiResponse>(Options(
|
_setStreamType<LoginResponseDtoApiResponse>(Options(
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: _headers,
|
headers: _headers,
|
||||||
extra: _extra,
|
extra: _extra,
|
||||||
|
)
|
||||||
|
.compose(
|
||||||
|
_dio.options,
|
||||||
|
'/api/v1/account/login-mobile',
|
||||||
|
queryParameters: queryParameters,
|
||||||
|
data: _data,
|
||||||
|
)
|
||||||
|
.copyWith(baseUrl: baseUrl ?? _dio.options.baseUrl)));
|
||||||
|
final value = LoginResponseDtoApiResponse.fromJson(_result.data!);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<LoginResponseDtoApiResponse> accountLogin(body) async {
|
||||||
|
const _extra = <String, dynamic>{};
|
||||||
|
final queryParameters = <String, dynamic>{};
|
||||||
|
final _headers = <String, dynamic>{};
|
||||||
|
final _data = FormData.fromMap(body);
|
||||||
|
final _result = await _dio.fetch<Map<String, dynamic>>(
|
||||||
|
_setStreamType<LoginResponseDtoApiResponse>(Options(
|
||||||
|
method: 'POST',
|
||||||
|
headers: _headers,
|
||||||
|
extra: _extra,
|
||||||
|
contentType: 'multipart/form-data',
|
||||||
)
|
)
|
||||||
.compose(
|
.compose(
|
||||||
_dio.options,
|
_dio.options,
|
||||||
@ -6447,6 +6472,28 @@ class _HraRepository implements HraRepository {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<dynamic> zoomWebhook() async {
|
||||||
|
const _extra = <String, dynamic>{};
|
||||||
|
final queryParameters = <String, dynamic>{};
|
||||||
|
final _headers = <String, dynamic>{};
|
||||||
|
final _data = <String, dynamic>{};
|
||||||
|
final _result = await _dio.fetch(_setStreamType<dynamic>(Options(
|
||||||
|
method: 'POST',
|
||||||
|
headers: _headers,
|
||||||
|
extra: _extra,
|
||||||
|
)
|
||||||
|
.compose(
|
||||||
|
_dio.options,
|
||||||
|
'/api/zoom-webhook',
|
||||||
|
queryParameters: queryParameters,
|
||||||
|
data: _data,
|
||||||
|
)
|
||||||
|
.copyWith(baseUrl: baseUrl ?? _dio.options.baseUrl)));
|
||||||
|
final value = _result.data;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
||||||
if (T != dynamic &&
|
if (T != dynamic &&
|
||||||
!(requestOptions.responseType == ResponseType.bytes ||
|
!(requestOptions.responseType == ResponseType.bytes ||
|
||||||
|
|||||||
@ -3369,6 +3369,11 @@ class ClassDetailDto {
|
|||||||
this.zoomMeetingId,
|
this.zoomMeetingId,
|
||||||
this.zoomPassword,
|
this.zoomPassword,
|
||||||
this.description,
|
this.description,
|
||||||
|
this.zoomHostVideo,
|
||||||
|
this.zoomParticipantVideo,
|
||||||
|
this.zoomJoinBeforeHost,
|
||||||
|
this.zoomMuteUponEntry,
|
||||||
|
this.zoomAutoRecording,
|
||||||
this.classUsers,
|
this.classUsers,
|
||||||
this.assignExams,
|
this.assignExams,
|
||||||
this.classSessions,
|
this.classSessions,
|
||||||
@ -3428,6 +3433,16 @@ class ClassDetailDto {
|
|||||||
String? zoomPassword;
|
String? zoomPassword;
|
||||||
@JsonKey(name: 'description', includeIfNull: true)
|
@JsonKey(name: 'description', includeIfNull: true)
|
||||||
String? description;
|
String? description;
|
||||||
|
@JsonKey(name: 'zoomHostVideo', includeIfNull: true)
|
||||||
|
bool? zoomHostVideo;
|
||||||
|
@JsonKey(name: 'zoomParticipantVideo', includeIfNull: true)
|
||||||
|
bool? zoomParticipantVideo;
|
||||||
|
@JsonKey(name: 'zoomJoinBeforeHost', includeIfNull: true)
|
||||||
|
bool? zoomJoinBeforeHost;
|
||||||
|
@JsonKey(name: 'zoomMuteUponEntry', includeIfNull: true)
|
||||||
|
bool? zoomMuteUponEntry;
|
||||||
|
@JsonKey(name: 'zoomAutoRecording', includeIfNull: true)
|
||||||
|
String? zoomAutoRecording;
|
||||||
@JsonKey(
|
@JsonKey(
|
||||||
name: 'classUsers',
|
name: 'classUsers',
|
||||||
includeIfNull: true,
|
includeIfNull: true,
|
||||||
@ -3478,6 +3493,11 @@ class ClassEntity {
|
|||||||
this.zoomMeetingId,
|
this.zoomMeetingId,
|
||||||
this.zoomPassword,
|
this.zoomPassword,
|
||||||
this.description,
|
this.description,
|
||||||
|
this.zoomHostVideo,
|
||||||
|
this.zoomParticipantVideo,
|
||||||
|
this.zoomJoinBeforeHost,
|
||||||
|
this.zoomMuteUponEntry,
|
||||||
|
this.zoomAutoRecording,
|
||||||
this.classUsers,
|
this.classUsers,
|
||||||
this.assignExams,
|
this.assignExams,
|
||||||
this.classSessions,
|
this.classSessions,
|
||||||
@ -3536,6 +3556,16 @@ class ClassEntity {
|
|||||||
String? zoomPassword;
|
String? zoomPassword;
|
||||||
@JsonKey(name: 'description', includeIfNull: true)
|
@JsonKey(name: 'description', includeIfNull: true)
|
||||||
String? description;
|
String? description;
|
||||||
|
@JsonKey(name: 'zoomHostVideo', includeIfNull: true)
|
||||||
|
bool? zoomHostVideo;
|
||||||
|
@JsonKey(name: 'zoomParticipantVideo', includeIfNull: true)
|
||||||
|
bool? zoomParticipantVideo;
|
||||||
|
@JsonKey(name: 'zoomJoinBeforeHost', includeIfNull: true)
|
||||||
|
bool? zoomJoinBeforeHost;
|
||||||
|
@JsonKey(name: 'zoomMuteUponEntry', includeIfNull: true)
|
||||||
|
bool? zoomMuteUponEntry;
|
||||||
|
@JsonKey(name: 'zoomAutoRecording', includeIfNull: true)
|
||||||
|
String? zoomAutoRecording;
|
||||||
@JsonKey(
|
@JsonKey(
|
||||||
name: 'classUsers',
|
name: 'classUsers',
|
||||||
includeIfNull: true,
|
includeIfNull: true,
|
||||||
@ -3669,6 +3699,11 @@ class ClassListDto {
|
|||||||
this.zoomMeetingId,
|
this.zoomMeetingId,
|
||||||
this.zoomPassword,
|
this.zoomPassword,
|
||||||
this.description,
|
this.description,
|
||||||
|
this.zoomHostVideo,
|
||||||
|
this.zoomParticipantVideo,
|
||||||
|
this.zoomJoinBeforeHost,
|
||||||
|
this.zoomMuteUponEntry,
|
||||||
|
this.zoomAutoRecording,
|
||||||
this.classUsers,
|
this.classUsers,
|
||||||
this.assignExams,
|
this.assignExams,
|
||||||
this.classSessions,
|
this.classSessions,
|
||||||
@ -3738,6 +3773,16 @@ class ClassListDto {
|
|||||||
String? zoomPassword;
|
String? zoomPassword;
|
||||||
@JsonKey(name: 'description', includeIfNull: true)
|
@JsonKey(name: 'description', includeIfNull: true)
|
||||||
String? description;
|
String? description;
|
||||||
|
@JsonKey(name: 'zoomHostVideo', includeIfNull: true)
|
||||||
|
bool? zoomHostVideo;
|
||||||
|
@JsonKey(name: 'zoomParticipantVideo', includeIfNull: true)
|
||||||
|
bool? zoomParticipantVideo;
|
||||||
|
@JsonKey(name: 'zoomJoinBeforeHost', includeIfNull: true)
|
||||||
|
bool? zoomJoinBeforeHost;
|
||||||
|
@JsonKey(name: 'zoomMuteUponEntry', includeIfNull: true)
|
||||||
|
bool? zoomMuteUponEntry;
|
||||||
|
@JsonKey(name: 'zoomAutoRecording', includeIfNull: true)
|
||||||
|
String? zoomAutoRecording;
|
||||||
@JsonKey(
|
@JsonKey(
|
||||||
name: 'classUsers',
|
name: 'classUsers',
|
||||||
includeIfNull: true,
|
includeIfNull: true,
|
||||||
@ -4179,6 +4224,7 @@ class ClassSessionEntity {
|
|||||||
this.zoomStartLink,
|
this.zoomStartLink,
|
||||||
this.zoomPassword,
|
this.zoomPassword,
|
||||||
this.recordingUrl,
|
this.recordingUrl,
|
||||||
|
this.zoomAccountIndex,
|
||||||
this.actualDurationMinutes,
|
this.actualDurationMinutes,
|
||||||
this.status,
|
this.status,
|
||||||
this.notes,
|
this.notes,
|
||||||
@ -4226,6 +4272,8 @@ class ClassSessionEntity {
|
|||||||
String? zoomPassword;
|
String? zoomPassword;
|
||||||
@JsonKey(name: 'recordingUrl', includeIfNull: true)
|
@JsonKey(name: 'recordingUrl', includeIfNull: true)
|
||||||
String? recordingUrl;
|
String? recordingUrl;
|
||||||
|
@JsonKey(name: 'zoomAccountIndex', includeIfNull: true)
|
||||||
|
int? zoomAccountIndex;
|
||||||
@JsonKey(name: 'actualDurationMinutes', includeIfNull: true)
|
@JsonKey(name: 'actualDurationMinutes', includeIfNull: true)
|
||||||
int? actualDurationMinutes;
|
int? actualDurationMinutes;
|
||||||
@JsonKey(
|
@JsonKey(
|
||||||
@ -8814,6 +8862,37 @@ class LocalityGetListQuery {
|
|||||||
Map<String, dynamic> toJson() => _$LocalityGetListQueryToJson(this);
|
Map<String, dynamic> toJson() => _$LocalityGetListQueryToJson(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class LoginDto {
|
||||||
|
LoginDto({
|
||||||
|
this.userName,
|
||||||
|
this.password,
|
||||||
|
this.rememberMe,
|
||||||
|
this.captchaText,
|
||||||
|
this.captchaToken,
|
||||||
|
this.captchaInputText,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory LoginDto.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$LoginDtoFromJson(json);
|
||||||
|
|
||||||
|
@JsonKey(name: 'userName', includeIfNull: true)
|
||||||
|
String? userName;
|
||||||
|
@JsonKey(name: 'password', includeIfNull: true)
|
||||||
|
String? password;
|
||||||
|
@JsonKey(name: 'rememberMe', includeIfNull: true)
|
||||||
|
bool? rememberMe;
|
||||||
|
@JsonKey(name: 'captchaText', includeIfNull: true)
|
||||||
|
String? captchaText;
|
||||||
|
@JsonKey(name: 'captchaToken', includeIfNull: true)
|
||||||
|
String? captchaToken;
|
||||||
|
@JsonKey(name: 'captchaInputText', includeIfNull: true)
|
||||||
|
String? captchaInputText;
|
||||||
|
static const fromJsonFactory = _$LoginDtoFromJson;
|
||||||
|
static const toJsonFactory = _$LoginDtoToJson;
|
||||||
|
Map<String, dynamic> toJson() => _$LoginDtoToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
@JsonSerializable(explicitToJson: true)
|
@JsonSerializable(explicitToJson: true)
|
||||||
class LoginResponseDto {
|
class LoginResponseDto {
|
||||||
LoginResponseDto({
|
LoginResponseDto({
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1 +1,2 @@
|
|||||||
const String appInitRouteName = '/app_init';
|
const String appInitRouteName = '/app_init';
|
||||||
|
const String loginRouteName = '/login';
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:baseproject/features/presentation/account/login_screen.dart';
|
||||||
import 'package:baseproject/features/presentation/home/view/home.dart';
|
import 'package:baseproject/features/presentation/home/view/home.dart';
|
||||||
import 'package:baseproject/features/route/route_const.dart';
|
import 'package:baseproject/features/route/route_const.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -9,6 +10,8 @@ class RouteGenerator {
|
|||||||
switch (setting.name) {
|
switch (setting.name) {
|
||||||
case appInitRouteName:
|
case appInitRouteName:
|
||||||
return MaterialPageRoute<void>(settings: setting, builder: (_) => const Home());
|
return MaterialPageRoute<void>(settings: setting, builder: (_) => const Home());
|
||||||
|
case loginRouteName:
|
||||||
|
return MaterialPageRoute<void>(settings: setting, builder: (_) => const LoginScreen());
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'route_const.dart';
|
||||||
|
|
||||||
|
void gotoLogin(BuildContext context) {
|
||||||
|
Navigator.pushNamed(context, loginRouteName);
|
||||||
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
import 'package:baseproject/features/model/index.dart';
|
|
||||||
import 'package:baseproject/features/repositories/hra_repository.dart';
|
import 'package:baseproject/features/repositories/hra_repository.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:injectable/injectable.dart';
|
import 'package:injectable/injectable.dart';
|
||||||
@ -11,7 +10,7 @@ class UserUseCases {
|
|||||||
|
|
||||||
Future<Either<String, LoginResponseDto>> loginAccount(LoginDto request) async {
|
Future<Either<String, LoginResponseDto>> loginAccount(LoginDto request) async {
|
||||||
try {
|
try {
|
||||||
final result = await _hraRepository.accountLogin(request);
|
final result = await _hraRepository.accountLoginMobile(request);
|
||||||
|
|
||||||
if (result.data == null) {
|
if (result.data == null) {
|
||||||
return Left<String, LoginResponseDto>(result.message ?? 'Login failed');
|
return Left<String, LoginResponseDto>(result.message ?? 'Login failed');
|
||||||
|
|||||||
@ -1,7 +1,18 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:baseproject/core/common/index.dart';
|
||||||
import 'package:baseproject/features/presentation/app/view/app.dart';
|
import 'package:baseproject/features/presentation/app/view/app.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
runZonedGuarded(() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
configureInjection();
|
||||||
|
await LocalStoreManager.init();
|
||||||
|
Loading.configLoading();
|
||||||
runApp(const App());
|
runApp(const App());
|
||||||
|
}, (error, stackTrace) {
|
||||||
|
print(error);
|
||||||
|
print(stackTrace);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user