mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
commit
f53ebc09b2
@ -83,7 +83,7 @@ public class OwnCloudClientFactory {
|
||||
am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||
OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso);
|
||||
|
||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
String username = AccountUtils.getUsernameForAccount(account);
|
||||
if (isOauth2) {
|
||||
String accessToken = am.blockingGetAuthToken(
|
||||
account,
|
||||
@ -137,7 +137,7 @@ public class OwnCloudClientFactory {
|
||||
am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||
OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso);
|
||||
|
||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
String username = AccountUtils.getUsernameForAccount(account);
|
||||
if (isOauth2) { // TODO avoid a call to getUserData here
|
||||
AccountManagerFuture<Bundle> future = am.getAuthToken(
|
||||
account,
|
||||
|
@ -147,6 +147,22 @@ public class AccountUtils {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the username corresponding to an OC account.
|
||||
*
|
||||
* @param account An OC account
|
||||
* @return Username for the given account, extracted from the account.name
|
||||
*/
|
||||
public static String getUsernameForAccount(Account account) {
|
||||
String username = null;
|
||||
try {
|
||||
username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Couldn't get a username for the given account", e);
|
||||
}
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
@ -168,7 +184,7 @@ public class AccountUtils {
|
||||
account,
|
||||
AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||
|
||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
String username = AccountUtils.getUsernameForAccount(account);
|
||||
|
||||
if (isOauth2) {
|
||||
String accessToken = am.blockingGetAuthToken(
|
||||
|
@ -217,6 +217,9 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, status, put.getResponseHeaders());
|
||||
}
|
||||
if (!result.isSuccess()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user