From 308acc09bfaf6dabf4b6d5f5e39f33854df8ce34 Mon Sep 17 00:00:00 2001 From: rsgowman Date: Wed, 21 Mar 2018 11:04:40 -0400 Subject: Change CredentialsProvider::TokenListener to use StatusOr (#945) * Change CredentialsProvider::TokenListener to use StatusOr Rather than a token plus error code/msg. * Eliminate the concept of an invalid Token Instead, we'll just use StatusOr. Note that unauthenticated tokens are handled as a special case; they're created via: Token::Unauthenticated() and are otherwise "valid", though attempting to retrieve the raw token on one of these tokens will cause an assertion failure. --- Firestore/core/src/firebase/firestore/auth/token.h | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'Firestore/core/src/firebase/firestore/auth/token.h') diff --git a/Firestore/core/src/firebase/firestore/auth/token.h b/Firestore/core/src/firebase/firestore/auth/token.h index ff8d2f0..4b2f3aa 100644 --- a/Firestore/core/src/firebase/firestore/auth/token.h +++ b/Firestore/core/src/firebase/firestore/auth/token.h @@ -46,7 +46,7 @@ class Token { /** The actual raw token. */ const std::string& token() const { - FIREBASE_ASSERT(is_valid_); + FIREBASE_ASSERT(user_.is_authenticated()); return token_; } @@ -59,25 +59,17 @@ class Token { } /** - * Whether the token is a valid one. + * Returns a token for an unauthenticated user. * - * ## Portability notes: Invalid token is the equivalent of nil in the iOS - * token implementation. We use value instead of pointer for Token instance in - * the C++ migration. + * ## Portability notes: An unauthenticated token is the equivalent of + * nil/null in the iOS/TypeScript token implementation. We use a reference + * instead of a pointer for Token instances in the C++ migration. */ - bool is_valid() const { - return is_valid_; - } - - /** Returns an invalid token. */ - static const Token& Invalid(); + static const Token& Unauthenticated(); private: - Token(); - const std::string token_; const User user_; - const bool is_valid_; }; } // namespace auth -- cgit v1.2.3