aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core/src/firebase/firestore/auth/token.h
diff options
context:
space:
mode:
authorGravatar rsgowman <rgowman@google.com>2018-03-21 11:04:40 -0400
committerGravatar GitHub <noreply@github.com>2018-03-21 11:04:40 -0400
commit308acc09bfaf6dabf4b6d5f5e39f33854df8ce34 (patch)
tree3706bbbe40d08569795634fd2f30a07fd348b399 /Firestore/core/src/firebase/firestore/auth/token.h
parentd924771453d000e708bd5d239da3bae4feb489ac (diff)
Change CredentialsProvider::TokenListener to use StatusOr<Token> (#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<Token>. 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.
Diffstat (limited to 'Firestore/core/src/firebase/firestore/auth/token.h')
-rw-r--r--Firestore/core/src/firebase/firestore/auth/token.h20
1 files changed, 6 insertions, 14 deletions
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