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); }
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; } }
public static boolean isUserAuthorized() { return mSimperium != null && mSimperium.getUser() != null && mSimperium.getUser().getStatus() == User.Status.AUTHORIZED; }