1 diff --git a/src/libcmis/oauth2-providers.cxx b/src/libcmis/oauth2-providers.cxx
2 index 74c0fec..30fedb0 100644
3 --- a/src/libcmis/oauth2-providers.cxx
4 +++ b/src/libcmis/oauth2-providers.cxx
6 #define CHALLENGE_PAGE_ACTION_LEN sizeof( CHALLENGE_PAGE_ACTION ) - 1
7 #define PIN_FORM_ACTION "/signin/challenge/ipp"
8 #define PIN_FORM_ACTION_LEN sizeof( PIN_FORM_ACTION ) - 1
9 +#define PIN_INPUT_NAME "Pin"
13 @@ -80,7 +81,7 @@ string OAuth2Providers::OAuth2Gdrive( HttpSession* session, const string& authUr
14 // send the first get, receive the html login page
15 res = session->httpGetRequest( authUrl )->getStream( )->str( );
17 - catch ( const CurlException& e )
18 + catch ( const CurlException& )
22 @@ -102,7 +103,7 @@ string OAuth2Providers::OAuth2Gdrive( HttpSession* session, const string& authUr
23 loginEmailRes = session->httpPostRequest ( loginEmailLink, loginEmailIs, CONTENT_TYPE )
24 ->getStream( )->str( );
26 - catch ( const CurlException& e )
27 + catch ( const CurlException& )
31 @@ -113,7 +114,7 @@ string OAuth2Providers::OAuth2Gdrive( HttpSession* session, const string& authUr
32 if ( !parseResponse( loginEmailRes.c_str( ), loginPasswdPost, loginPasswdLink ) )
35 - loginPasswdPost += "&Passwd=";
36 + loginPasswdPost += "Passwd=";
37 loginPasswdPost += string( password );
39 istringstream loginPasswdIs( loginPasswdPost );
40 @@ -124,7 +125,7 @@ string OAuth2Providers::OAuth2Gdrive( HttpSession* session, const string& authUr
41 loginPasswdRes = session->httpPostRequest ( loginPasswdLink, loginPasswdIs, CONTENT_TYPE )
42 ->getStream( )->str( );
44 - catch ( const CurlException& e )
45 + catch ( const CurlException& )
49 @@ -152,7 +153,7 @@ string OAuth2Providers::OAuth2Gdrive( HttpSession* session, const string& authUr
52 loginChallengeLink = "https://accounts.google.com" + loginChallengeLink;
53 - loginChallengePost += "Pin=";
54 + loginChallengePost += string( PIN_INPUT_NAME ) + "=";
55 loginChallengePost += string( pin );
57 istringstream loginChallengeIs( loginChallengePost );
58 @@ -163,7 +164,7 @@ string OAuth2Providers::OAuth2Gdrive( HttpSession* session, const string& authUr
59 loginChallengeRes = session->httpPostRequest ( loginChallengeLink, loginChallengeIs, CONTENT_TYPE )
60 ->getStream( )->str( );
62 - catch ( const CurlException& e )
63 + catch ( const CurlException& )
67 @@ -221,7 +222,7 @@ string OAuth2Providers::OAuth2Alfresco( HttpSession* session, const string& auth
69 res = session->httpGetRequest( authUrl )->getStream( )->str( );
71 - catch ( const CurlException& e )
72 + catch ( const CurlException& )
76 @@ -247,7 +248,7 @@ string OAuth2Providers::OAuth2Alfresco( HttpSession* session, const string& auth
77 // Alfresco code is in the redirect link
78 resp = session->httpPostRequest( loginLink, loginIs, CONTENT_TYPE, false );
80 - catch ( const CurlException& e )
81 + catch ( const CurlException& )
85 @@ -291,6 +292,8 @@ int OAuth2Providers::parseResponse ( const char* response, string& post, string&
86 if ( reader == NULL ) return 0;
88 bool readInputField = false;
89 + bool bIsRightForm = false;
90 + bool bHasPinField = false;
94 @@ -301,6 +304,12 @@ int OAuth2Providers::parseResponse ( const char* response, string& post, string&
95 // Find the redirect link
96 if ( xmlStrEqual( nodeName, BAD_CAST( "form" ) ) )
98 + // 2FA: Don't add fields form other forms not having pin field
99 + if ( bIsRightForm && !bHasPinField )
100 + post = string( "" );
101 + if ( bIsRightForm && bHasPinField )
104 xmlChar* action = xmlTextReaderGetAttribute( reader,
105 BAD_CAST( "action" ));
107 @@ -311,7 +320,7 @@ int OAuth2Providers::parseResponse ( const char* response, string& post, string&
108 bool bChallengePage = ( strncmp( (char*)action,
109 CHALLENGE_PAGE_ACTION,
110 CHALLENGE_PAGE_ACTION_LEN ) == 0 );
111 - bool bIsRightForm = ( strncmp( (char*)action,
112 + bIsRightForm = ( strncmp( (char*)action,
114 PIN_FORM_ACTION_LEN ) == 0 );
115 if ( ( xmlStrlen( action ) > 0 )
116 @@ -332,6 +341,8 @@ int OAuth2Providers::parseResponse ( const char* response, string& post, string&
118 xmlChar* value = xmlTextReaderGetAttribute( reader,
119 BAD_CAST( "value" ));
120 + if ( name != NULL && strcmp( (char*)name, PIN_INPUT_NAME ) == 0 )
121 + bHasPinField = true;
122 if ( ( name != NULL ) && ( value!= NULL ) )
124 if ( ( xmlStrlen( name ) > 0) && ( xmlStrlen( value ) > 0) )