@@ -1585,12 +1585,17 @@ - (void)textFieldDidEndEditing:(UITextField *)textField {
1585
1585
NSString *urlWithoutUserPassword = [self stripUsernameAndPassword: self .urlTextField.text];
1586
1586
self.auxUrlForReloadTable = [self stripIndexPhpOrAppsFilesFromUrl: urlWithoutUserPassword];
1587
1587
} else {
1588
- // This is when we deleted the last account and go to the login screen
1588
+ // This is when we deleted the last account and go to the login screen and when edit credentials in settings view
1589
1589
self.urlTextField = [[UITextField alloc ]initWithFrame:self .urlFrame];
1590
1590
self.urlTextField .text = self.auxUrlForReloadTable ;
1591
1591
textField = self.urlTextField ;
1592
1592
}
1593
1593
1594
+ if (self.usernameTextField .text == nil ) {
1595
+ self.usernameTextField = [[UITextField alloc ]initWithFrame:self .userAndPasswordFrame];
1596
+ self.usernameTextField .text = self.auxUsernameForReloadTable ;
1597
+ }
1598
+
1594
1599
self.auxUsernameForReloadTable = self.usernameTextField .text ;
1595
1600
self.auxPasswordForReloadTable = self.passwordTextField .text ;
1596
1601
@@ -1672,6 +1677,10 @@ -(void) isConnectionToTheServerByUrlInOtherThread {
1672
1677
isCheckingTheServerRightNow = YES ;
1673
1678
isConnectionToServer = NO ;
1674
1679
1680
+ // Reset the url of redirected server at this point
1681
+ AppDelegate *app = (AppDelegate*)[[UIApplication sharedApplication ] delegate ];
1682
+ app.urlServerRedirected = nil ;
1683
+
1675
1684
[[CheckAccessToServer sharedManager ] isConnectionToTheServerByUrl: [self getUrlToCheck ]];
1676
1685
}
1677
1686
@@ -1980,39 +1989,42 @@ - (void) checkIfServerAutentificationIsNormalFromURL {
1980
1989
});
1981
1990
} failureRequest: ^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
1982
1991
1983
- BOOL isInvalid = NO ;
1992
+ BOOL isInvalid = YES ;
1993
+
1994
+ NSString *authenticationHeader = @" Www-Authenticate" ;
1995
+ NSString *outhAuthentication = @" bearer" ;
1996
+ NSString *basicAuthentication = @" basic" ;
1984
1997
1985
1998
if (!k_is_sso_active) {
1986
- // Get header related with autentication type
1987
- NSString *autenticationType = [[response allHeaderFields ] valueForKey: @" Www-Authenticate" ];
1988
-
1989
- if (autenticationType) {
1990
- // Autentication type basic
1991
- if ([autenticationType hasPrefix: @" Basic" ]) {
1992
- isInvalid = NO ;
1993
- } else if ([autenticationType hasPrefix: @" Bearer" ]) {
1999
+ if (response.statusCode == kOCErrorServerUnauthorized ) {
2000
+ // Get header related with autentication type
2001
+ NSString *autenticationType = [[response allHeaderFields ] valueForKey: authenticationHeader];
2002
+
2003
+ if ((autenticationType) && ([autenticationType.lowercaseString hasPrefix: outhAuthentication])) {
1994
2004
// Autentication type oauth
1995
2005
if (k_is_oauth_active) {
1996
2006
// Check if is activate oauth
1997
2007
isInvalid = NO ;
1998
2008
} else {
1999
2009
isInvalid = YES ;
2000
2010
}
2011
+ } else if ((autenticationType) && ([autenticationType.lowercaseString hasPrefix: basicAuthentication])) {
2012
+ isInvalid = NO ;
2001
2013
} else {
2002
- // Unknown autentication type
2003
- isInvalid = YES ;
2014
+ // For the moment we have to mantain this value as valid because when we work with
2015
+ // some Redirected Server our library lost the Wwww-Authenticate header
2016
+ isInvalid = NO ;
2004
2017
}
2005
- } else {
2006
- // The server not return a Www-Authenticate header
2007
- isInvalid = YES ;
2008
2018
}
2019
+
2009
2020
} else {
2010
2021
// If sso_active the check does not fail
2011
2022
// As we are receiving a SAML error from SAML server, we forced the flag to accept this connection
2012
2023
isInvalid = NO ;
2013
2024
isLoginButtonEnabled = YES ;
2014
2025
}
2015
2026
2027
+
2016
2028
// Update the interface depend of if isInvalid or not
2017
2029
if (isInvalid) {
2018
2030
hasInvalidAuth = YES ;
@@ -2208,6 +2220,8 @@ -(void)createUserAndDataInTheSystemWithRequest:(NSArray *)items andCode:(NSInteg
2208
2220
userDto.password = passwordUTF8;
2209
2221
userDto.ssl = isHttps;
2210
2222
userDto.activeaccount = YES ;
2223
+ // Take into account that this global property can be stored bab value
2224
+ // For that we reset this property when the system check the server in LoginViewController class
2211
2225
userDto.urlRedirected = app.urlServerRedirected ;
2212
2226
2213
2227
[ManageUsersDB insertUser: userDto];
0 commit comments