| // Copyright 2017 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef SRC_LEDGER_LIB_FIREBASE_AUTH_FIREBASE_AUTH_H_ |
| #define SRC_LEDGER_LIB_FIREBASE_AUTH_FIREBASE_AUTH_H_ |
| |
| #include <lib/callback/cancellable.h> |
| #include <lib/fit/function.h> |
| |
| #include <functional> |
| #include <string> |
| |
| #include "src/lib/fxl/macros.h" |
| |
| namespace firebase_auth { |
| |
| enum class AuthStatus { |
| OK, |
| // Failed to retrieve the auth token. |
| ERROR |
| }; |
| |
| // Source of Firebase Auth tokens that can be used to authenticate with Firebase |
| // services such as Firebase Real-Time Database, Firebase Storage or Firestore. |
| // |
| // Each instance of this class is tied to exactly one user. |
| class FirebaseAuth { |
| public: |
| FirebaseAuth() {} |
| virtual ~FirebaseAuth() {} |
| |
| virtual void set_error_handler(fit::closure /*on_error*/) {} |
| |
| // Retrieves the Firebase ID token suitable to use with Firebase Real-time |
| // Database and Firebase Storage. |
| virtual fxl::RefPtr<callback::Cancellable> GetFirebaseToken( |
| fit::function<void(AuthStatus, std::string)> callback) = 0; |
| |
| // Retrieves the Firebase user ID of the user. |
| virtual fxl::RefPtr<callback::Cancellable> GetFirebaseUserId( |
| fit::function<void(AuthStatus, std::string)> callback) = 0; |
| |
| private: |
| FXL_DISALLOW_COPY_AND_ASSIGN(FirebaseAuth); |
| }; |
| |
| } // namespace firebase_auth |
| |
| #endif // SRC_LEDGER_LIB_FIREBASE_AUTH_FIREBASE_AUTH_H_ |