io7m / android

The Android client for Library Simplified
Other
0 stars 0 forks source link

HTTP auth copy/paste #14

Closed io7m closed 6 years ago

io7m commented 6 years ago

This same bit of code has been copied and pasted repeatedly throughout the codebase:

    final AccountAuthenticationCredentials credentials = this.getAccountCredentials();
    final AccountBarcode barcode = credentials.getBarcode();
    final AccountPIN pin = credentials.getPin();

    HTTPAuthType auth = HTTPAuthBasic.create(barcode.toString(), pin.toString());
    if (credentials.getOAuthToken().isSome()) {
      final HTTPOAuthToken token = ((Some<HTTPOAuthToken>) credentials.getOAuthToken()).get();
      if (token != null) {
        auth = HTTPAuthOAuth.create(token);
      }
    }

    return auth;

This needs to go in a method somewhere instead of being endlessly replicated.

io7m commented 6 years ago

These all appear to have been replaced now.