Files
superport/lib/domain/usecases/auth/refresh_token_usecase.dart
JiWoong Sul 655d473413
Some checks failed
Flutter Test & Quality Check / Test on macos-latest (push) Has been cancelled
Flutter Test & Quality Check / Test on ubuntu-latest (push) Has been cancelled
Flutter Test & Quality Check / Build APK (push) Has been cancelled
web: migrate health notifications to js_interop; add browser hook
- Replace dart:js with package:js in health_check_service_web.dart\n- Implement showHealthCheckNotification in web/index.html\n- Pin js dependency to ^0.6.7 for flutter_secure_storage_web compatibility

auth: harden AuthInterceptor + tests

- Allow overrideAuthRepository injection for testing\n- Normalize imports to package: paths\n- Add unit test covering token attach, 401→refresh→retry, and failure path\n- Add integration test skeleton gated by env vars

ui/data: map User.companyName to list column

- Add companyName to domain User\n- Map UserDto.company?.name\n- Render companyName in user_list

cleanup: remove legacy equipment table + unused code; minor warnings

- Remove _buildFlexibleTable and unused helpers\n- Remove unused zipcode details and cache retry constant\n- Fix null-aware and non-null assertions\n- Address child-last warnings in administrator dialog

docs: update AGENTS.md session context
2025-09-08 17:39:00 +09:00

34 lines
1.1 KiB
Dart

import 'package:dartz/dartz.dart';
import '../../../data/models/auth/token_response.dart';
import '../../../data/models/auth/refresh_token_request.dart';
import '../../repositories/auth_repository.dart';
import '../../../core/errors/failures.dart';
import '../base_usecase.dart';
/// 토큰 갱신 UseCase
/// JWT 토큰을 갱신하여 세션 유지
class RefreshTokenUseCase extends UseCase<TokenResponse, NoParams> {
// AuthRepository 기반으로 마이그레이션
final AuthRepository _authRepository;
RefreshTokenUseCase(this._authRepository);
@override
Future<Either<Failure, TokenResponse>> call(NoParams params) async {
final stored = await _authRepository.getStoredRefreshToken();
return await stored.fold(
(failure) => Left(failure),
(token) async {
if (token == null || token.isEmpty) {
return Left(AuthFailure(
message: '갱신 토큰이 없습니다. 다시 로그인해주세요.',
code: 'NO_REFRESH_TOKEN',
));
}
final request = RefreshTokenRequest(refreshToken: token);
return await _authRepository.refreshToken(request);
},
);
}
}