Ejemplo n.º 1
0
  private static void authorizeUser(Simperium simperium, String token) {
    User user = simperium.getUser();

    String tokenFormat = "WPCC/%s/%s";
    String wpccToken =
        String.format(tokenFormat, BuildConfig.SIMPERIUM_APP_SECRET, StringUtils.notNullStr(token));

    user.setAccessToken(wpccToken);

    // we'll assume the user is AUTHORIZED, and catch NOT_AUTHORIZED if something goes wrong.
    user.setStatus(User.Status.AUTHORIZED);
  }
Ejemplo n.º 2
0
  public static void resetBucketsAndDeauthorize() {
    if (mNotesBucket != null) {
      mNotesBucket.reset();
      mNotesBucket = null;
    }
    if (mMetaBucket != null) {
      mMetaBucket.reset();
      mMetaBucket = null;
    }

    // Reset user status
    if (mSimperium != null) {
      mSimperium.getUser().setStatus(User.Status.UNKNOWN);
      mSimperium = null;
    }
  }
Ejemplo n.º 3
0
 public static boolean isUserAuthorized() {
   return mSimperium != null
       && mSimperium.getUser() != null
       && mSimperium.getUser().getStatus() == User.Status.AUTHORIZED;
 }