Pages

Tuesday, 1 September 2015

Firebase Auth

Documentation
Element wrapper for the Firebase authentication API (https://www.firebase.com/docs/web/guide/user-auth.html).
Properties
autoLogin
Booleandefault: false
    When true, login will be attempted if login status check determines no user is logged in. Should generally only be used with provider types that do not present a login UI, such as 'anonymous'.
    location
    String
      Firebase location URL (must have simple login enabled via Forge interface).
      options
      Object
        Provider-specific options to pass to login, for provider types that take a second object to pass firebase-specific options. May be overridden atlogin()-time.
        params
        Object
          Provider-specific parameters to pass to login. May be overridden atlogin()-time.
          provider
          Stringdefault: anonymous
            Default login provider type. May be one of: anonymouscustom,password facebookgithubtwittergoogle.
            redirect
            Booleandefault: false
              When true, authentication will try to redirect instead of using a popup if possible.
              ref
              Object readOnly notify
                A pointer to the Firebase instance being used by the firebase-auth element.
                statusKnown
                Booleandefault: false readOnly notify
                  When true, login status can be determined by checking user property.
                  user
                  Object readOnly notify
                    When logged in, this property reflects the firebase user auth object.
                    Methods
                    changeEmail(oldEmail, newEmail, password)
                    1. oldEmail string 
                    2. newEmail string 
                    Changes the email of a "password provider"-based user account.
                    If the operation is successful, the email-changed event is fired.
                    If the operation fails, the error event is fired, with e.detail containing error information supplied from Firebase.
                    changePassword(email, oldPassword, newPassword)
                    1. email string 
                    2. oldPassword string 
                    3. newPassword string 
                    Changes the password of a "password provider"-based user account.
                    If the operation is successful, the password-changed event is fired.
                    If the operation fails, the error event is fired, with e.detail containing error information supplied from Firebase.
                    createUser(email, password)
                    1. email string 
                    2. password string 
                    Creates a "password provider"-based user account.
                    If the operation is successful, the user-created event is fired.
                    If the operation fails, the error event is fired, with e.detail containing error information supplied from Firebase.
                    login(params, options)
                    1. params string 
                      (optional)
                    2. options string 
                      (optional)
                    Performs a login attempt, using the provider specified via attribute/property, or optionally via provider argument to the loginfunction. Optionally, provider-specific login parameters can be specified via attribute (JSON)/property, or via the params argument to the loginfunction.
                    If the login is successful, the login event is fired, with e.detail.usercontaining the authenticated user object from Firebase.
                    If login fails, the error event is fired, with e.detail containing error information supplied from Firebase.
                    If the browswer supports navigator.onLine network status reporting and the network is currently offline, the login attempt will be queued until the network is restored.
                    logout()
                      Performs a logout attempt.
                      If the login is successful, the logout event is fired.
                      If login fails, the error event is fired, with e.detail containing error information supplied from Firebase.
                      If the browswer supports navigator.onLine network status reporting and the network is currently offline, the logout attempt will be queued until the network is restored.
                      removeUser(email, password)
                      1. email string 
                      2. password string 
                      Removes a "password provider"-based user account.
                      If the operation is successful, the user-removed event is fired.
                      If the operation fails, the error event is fired, with e.detail containing error information supplied from Firebase.
                      sendPasswordResetEmail(email)
                      1. email string 
                      Sends a password reset email for a "password provider"-based user account.
                      If the operation is successful, the password-reset event is fired.
                      If the operation fails, the error event is fired, with e.detail containing error information supplied from Firebase.

                      Firebase Document

                      Documentation
                      An element wrapper for the Firebase API.
                      <firebase-document> is a reference to a remote document somewhere on Firebase. The element fetchs a document at a provided location, and exposes it as an Object that is suitable for deep two-way databinding.
                      Example:
                      <firebase-document
                        location="https://dinosaur-facts.firebaseio.com/dinosaurs"
                        data="{{dinosaurs}}">
                      
                      In the above example, if the dinosaurs object is data-bound elsewhere via Polymer's data-binding system, changes to the document will be automatically reflected in the remote document and any other clients referencing that document.
                      Properties
                      data
                      Object notify
                        The data object mapped to location.
                        query
                        Object notify
                          Firebase Query object corresponding to location.
                          Behaviors
                          Polymer.FirebaseQueryBehavior

                          Firebase Collection

                          Documentation
                          An element wrapper for the Firebase API that provides a view into the provided Firebase location as an ordered collection.
                          By default, Firebase yields values as unsorted document objects, where each of the children are accessible via object keys. The <firebase-collection> element allows Firebase API orderBy, limitTo and other query-oriented methods to be specified declaratively. The element then produces and maintains an Array of ordered child items of the document that is convenient for iterating over in other elements such as <template is="dom-repeat">.
                          Example:
                            <template is="dom-bind">
                              <firebase-collection
                                order-by-child="height"
                                limit-to-first="3"
                                location="https://dinosaur-facts.firebaseio.com/dinosaurs"
                                data="{{dinosaurs}}"></firebase-collection>
                              <template is="dom-repeat" items="[[dinosaurs]]" as="dinosaur">
                                <h4>[[dinosaur.__firebaseKey__]]</h4>
                                <span>Height: </span><span>[[dinosaur.height]]</span><span>m</span>
                              </template>
                            </template>
                          
                          As you may have noticed above, the original key of each item is available as the__firebaseKey__ property on the item.
                          The element makes special accomodations for documents whose children are primitive values. A primitive value is wrapped in an object with the form:
                          {
                            value: /* original primitive value */
                            __firebaseKey__: /* key of primitive value in parent document */
                          }
                          
                          Accessor methods such as add and remove are provided to enable convenient manipulation of the collection without direct knowledge of Firebase key values.
                          Properties
                          data
                          Arraydefault: [] readOnly notify
                            An ordered array of data items produced by the current Firebase Query instance.
                            endAt
                            Stringdefault:
                              Specify an end record for the set of records reflected in the collection.
                              equalTo
                              Stringdefault:
                                Specify to create a query which includes children which match the specified value. The argument type depends on which orderBy() function was used in this query. Specify a value that matches the orderBy() type.
                                limitToFirst
                                Numberdefault:
                                  Specify a maximum number of records reflected on the client limited to the first certain number of children.
                                  limitToLast
                                  Numberdefault:
                                    Specify a maximum number of records reflected on the client limited to the last certain number of children.
                                    orderByChild
                                    Stringdefault:
                                      Specify a child key to order the set of records reflected on the client.
                                      orderByKey
                                      Booleandefault: false
                                        Specify to order by key the set of records reflected on the client.
                                        orderByPriority
                                        Booleandefault: false
                                          Specify to order by priority the set of records reflected on the client.
                                          orderByValue
                                          Booleandefault: false
                                            Specify to order by value the set of records reflected on the client.
                                            orderValueType
                                            Stringdefault: string
                                              Specify to override the type used when deserializing the value of start-atend-at and equal-to attributes. By default, these values are always deserialized as String, but sometimes it is preferrable to deserialize these values as e.g., Number.
                                              Accepted values for this attribute, and their corresponding deserialization types, are as follows:
                                              • string => String (default)
                                              • number => Number
                                              • boolean => Boolean
                                              query
                                              Object notify
                                                A pointer to the current Firebase Query instance being used to populatedata.
                                                startAt
                                                Stringdefault:
                                                  Specify a start record for the set of records reflected in the collection.
                                                  Methods
                                                  add(data) ➙ Object
                                                  1. data Object 
                                                    A value to add to the document.
                                                  2. Returns Object
                                                    A Firebase Query instance referring to the added item.
                                                  Add an item to the document referenced at location. A key associated with the item will be created by Firebase, and can be accessed via the Firebase Query instance returned by this method.
                                                  getByKey(key)
                                                  1. key String
                                                    The key associated with the item in the parent document.
                                                  Look up an item in the local data Array by key.
                                                  remove(data)
                                                  1. data Object 
                                                    An identical reference to an item in this.data.
                                                  Remove an item from the document referenced at location. The item is assumed to be an identical reference to an item already in the dataArray.
                                                  removeByKey(key)
                                                  1. key String
                                                    The key associated with the item in the document located at location.
                                                  Remove an item from the document associated with location by key.
                                                  Behaviors
                                                  Polymer.FirebaseQueryBehavior