Skip to content

Commit 6541c6b

Browse files
committed
Update the method where the auth is checked
1 parent 42494e4 commit 6541c6b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

Owncloud iOs Client/Login/Login/LoginViewController.m

+17-7
Original file line numberDiff line numberDiff line change
@@ -1989,23 +1989,32 @@ - (void) checkIfServerAutentificationIsNormalFromURL {
19891989
});
19901990
} failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
19911991

1992-
BOOL isInvalid = NO;
1992+
BOOL isInvalid = YES;
1993+
1994+
NSString *authenticationHeader = @"Www-Authenticate";
1995+
NSString *outhAuthentication = @"bearer";
1996+
NSString *basicAuthentication = @"basic";
19931997

19941998
if (!k_is_sso_active) {
1995-
//Get header related with autentication type
1996-
NSString *autenticationType = [[response allHeaderFields] valueForKey:@"Www-Authenticate"];
1997-
1998-
if ((autenticationType) && ([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])) {
19992004
//Autentication type oauth
20002005
if (k_is_oauth_active) {
20012006
//Check if is activate oauth
20022007
isInvalid = NO;
20032008
} else {
20042009
isInvalid = YES;
20052010
}
2006-
} else {
2007-
//Unknown autentication type
2011+
} else if ((autenticationType) && ([autenticationType.lowercaseString hasPrefix:basicAuthentication])) {
20082012
isInvalid = NO;
2013+
} else {
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;
2017+
}
20092018
}
20102019

20112020
} else {
@@ -2015,6 +2024,7 @@ - (void) checkIfServerAutentificationIsNormalFromURL {
20152024
isLoginButtonEnabled = YES;
20162025
}
20172026

2027+
20182028
//Update the interface depend of if isInvalid or not
20192029
if (isInvalid) {
20202030
hasInvalidAuth = YES;

0 commit comments

Comments
 (0)