From 7a4a2ea10844afd6a58dace46854fae74399f55c Mon Sep 17 00:00:00 2001 From: zxu Date: Tue, 20 Feb 2018 12:25:39 -0500 Subject: replacing FSTGetTokenResult by C++ Token implementation (#805) * replacing Auth/FSTUser by C++ auth implementation * address changes * replacing FSTGetTokenResult by C++ Token implementation * address changes * address changes * fix another const& v.s. dispatch bug * fix more const& v.s. dispatch bug zxu123 committed * fix * passing by value in callback --- Firestore/core/src/firebase/firestore/auth/token.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (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 f3b7363..ff8d2f0 100644 --- a/Firestore/core/src/firebase/firestore/auth/token.h +++ b/Firestore/core/src/firebase/firestore/auth/token.h @@ -20,6 +20,7 @@ #include #include "Firestore/core/src/firebase/firestore/auth/user.h" +#include "Firestore/core/src/firebase/firestore/util/firebase_assert.h" #include "absl/strings/string_view.h" namespace firebase { @@ -45,6 +46,7 @@ class Token { /** The actual raw token. */ const std::string& token() const { + FIREBASE_ASSERT(is_valid_); return token_; } @@ -56,9 +58,26 @@ class Token { return user_; } + /** + * Whether the token is a valid one. + * + * ## 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. + */ + bool is_valid() const { + return is_valid_; + } + + /** Returns an invalid token. */ + static const Token& Invalid(); + private: + Token(); + const std::string token_; const User user_; + const bool is_valid_; }; } // namespace auth -- cgit v1.2.3