File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed
Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -35,25 +35,21 @@ public class QsoSyncAssistantUtil
3535 public static async Task < IReadOnlyList < FlurlCookie > > LoginAndGetCookies ( string baseurl , string username ,
3636 string password , CancellationToken cancellationToken )
3737 {
38- var tmp = new JsonObject ( ) ;
39- tmp . Add ( "user_name" , username ) ;
40- tmp . Add ( "user_password" , password ) ;
41-
42- var formData = tmp
43- . ToDictionary (
44- kvp => kvp . Key ,
45- kvp => kvp . Value ? . ToString ( )
46- ) ;
47-
48-
4938 var loginRequest = baseurl
5039 . AllowHttpStatus ( 303 )
5140 . WithAutoRedirect ( false )
5241 . AppendPathSegments ( DefaultConfigs . CloudlogLoginEndpoint ) ;
5342
5443 var result = await loginRequest
55- . PostUrlEncodedAsync ( formData , default , cancellationToken ) . ConfigureAwait ( false ) ;
44+ . PostUrlEncodedAsync ( new
45+ {
46+ user_name = username ,
47+ user_password = password
48+ } , cancellationToken : cancellationToken )
49+ . ConfigureAwait ( false ) ;
50+
5651 var redirectUrl = result . Headers . FirstOrDefault ( "Location" ) ;
52+ if ( redirectUrl is null ) throw new InvalidOperationException ( "Username or password should not be empty!" ) ;
5753 if ( ! redirectUrl . Contains ( "dashboard" ) ) throw new InvalidOperationException ( "Incorrect username or password" ) ;
5854 if ( cancellationToken . IsCancellationRequested )
5955 throw new OperationCanceledException ( "Operation(LoginAndGetCookies) was canceled." ) ;
You can’t perform that action at this time.
0 commit comments