11import 'dart:async' ;
22import 'dart:convert' ;
33
4- import 'package:aha_client/src/api/login/login_info.dart' ;
54import 'package:chopper/chopper.dart' ;
65import 'package:convert/convert.dart' ;
76import 'package:cryptography/cryptography.dart' ;
87import 'package:meta/meta.dart' ;
98
109import 'authentication_exception.dart' ;
10+ import 'login_info.dart' ;
1111import 'login_service.dart' ;
1212import 'models/right.dart' ;
1313import 'models/session_info.dart' ;
@@ -86,7 +86,11 @@ abstract class LoginManager implements RequestInterceptor, Authenticator {
8686
8787 @override
8888 @internal
89- FutureOr <Request ?> authenticate (Request request, Response response) async {
89+ FutureOr <Request ?> authenticate (
90+ Request request,
91+ Response response, [
92+ Request ? originalRequest,
93+ ]) async {
9094 if (response.statusCode != 403 || request.isLogin) {
9195 return null ;
9296 }
@@ -102,7 +106,7 @@ abstract class LoginManager implements RequestInterceptor, Authenticator {
102106 }
103107
104108 Request _copyRequestWithSid (Request request) => request.copyWith (
105- parameters: {
109+ parameters: < String , dynamic > {
106110 ...request.parameters,
107111 'sid' : _sid,
108112 },
@@ -118,13 +122,11 @@ abstract class LoginManager implements RequestInterceptor, Authenticator {
118122 }
119123 }
120124
121- Future <SessionInfo > _getLoginStatus () async {
122- return _extractSessionInfo (
123- _sid == SessionInfo .invalidSid
124- ? await _loginService.getLoginStatus ()
125- : await _loginService.checkSessionValid (sid: _sid),
126- );
127- }
125+ Future <SessionInfo > _getLoginStatus () async => _extractSessionInfo (
126+ _sid == SessionInfo .invalidSid
127+ ? await _loginService.getLoginStatus ()
128+ : await _loginService.checkSessionValid (sid: _sid),
129+ );
128130
129131 Future <SessionInfo > _performLogin (
130132 SessionInfo sessionInfo,
@@ -133,7 +135,8 @@ abstract class LoginManager implements RequestInterceptor, Authenticator {
133135 final blockDelay = sessionInfo.blockTime > 0
134136 ? Duration (seconds: sessionInfo.blockTime)
135137 : null ;
136- final blockTimeout = blockDelay != null ? Future .delayed (blockDelay) : null ;
138+ final blockTimeout =
139+ blockDelay != null ? Future <void >.delayed (blockDelay) : null ;
137140
138141 final credentials = await obtainCredentials (
139142 LoginInfo (
@@ -216,5 +219,5 @@ abstract class LoginManager implements RequestInterceptor, Authenticator {
216219}
217220
218221extension _RequestX on Request {
219- bool get isLogin => url.contains ('/login_sid.lua' );
222+ bool get isLogin => url.path. endsWith ('/login_sid.lua' );
220223}
0 commit comments