mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-16 10:12:32 -06:00
Refactored DI, serialization, added feedback to document download
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/store/local_vault.dart';
|
||||
import 'package:http_interceptor/http_interceptor.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:paperless_mobile/core/store/local_vault.dart';
|
||||
|
||||
@injectable
|
||||
@dev
|
||||
@prod
|
||||
@injectable
|
||||
class AuthenticationInterceptor implements InterceptorContract {
|
||||
final LocalVault _localVault;
|
||||
AuthenticationInterceptor(this._localVault);
|
||||
@@ -20,15 +18,15 @@ class AuthenticationInterceptor implements InterceptorContract {
|
||||
if (kDebugMode) {
|
||||
log("Intercepted ${request.method} request to ${request.url.toString()}");
|
||||
}
|
||||
if (auth == null) {
|
||||
throw const PaperlessServerException(ErrorCode.notAuthenticated);
|
||||
}
|
||||
|
||||
return request.copyWith(
|
||||
//Append server Url
|
||||
url: Uri.parse(auth.serverUrl + request.url.toString()),
|
||||
headers: auth.token.isEmpty
|
||||
headers: auth?.token?.isEmpty ?? true
|
||||
? request.headers
|
||||
: {...request.headers, 'Authorization': 'Token ${auth.token}'},
|
||||
: {
|
||||
...request.headers,
|
||||
'Authorization': 'Token ${auth!.token}',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user