@@ -6,12 +6,12 @@ Firestack handles authentication for us out of the box, both with email/password
66
77## Local Auth
88
9- #### [ listenForAuth ()] ( https://firebase.google.com/docs/reference/js/firebase.auth.Auth#onAuthStateChanged )
9+ #### [ onAuthStateChanged ()] ( https://firebase.google.com/docs/reference/js/firebase.auth.Auth#onAuthStateChanged )
1010
1111Listen for changes in the users auth state (logging in and out).
1212
1313``` javascript
14- firestack .auth . listenForAuth ((evt ) => {
14+ firestack .auth (). onAuthStateChanged ((evt ) => {
1515 // evt is the authentication event, it contains an `error` key for carrying the
1616 // error message in case of an error and a `user` key upon successful authentication
1717 if (! evt .authenticated ) {
@@ -25,22 +25,22 @@ firestack.auth.listenForAuth((evt) => {
2525.then (() => console .log (' Listening for authentication changes' ))
2626```
2727
28- #### unlistenForAuth ()
28+ #### offAuthStateChanged ()
2929
30- Remove the ` listenForAuth ` listener.
30+ Remove the ` onAuthStateChanged ` listener.
3131This is important to release resources from our app when we don't need to hold on to the listener any longer.
3232
3333``` javascript
34- firestack .auth . unlistenForAuth ()
34+ firestack .auth (). offAuthStateChanged ()
3535```
3636
37- #### [ createUserWithEmail ()] ( https://firebase.google.com/docs/reference/js/firebase.auth.Auth#createUserWithEmailAndPassword )
37+ #### [ createUserWithEmailAndPassword ()] ( https://firebase.google.com/docs/reference/js/firebase.auth.Auth#createUserWithEmailAndPassword )
3838
39- We can create a user by calling the ` createUserWithEmail ()` function.
39+ We can create a user by calling the ` createUserWithEmailAndPassword ()` function.
4040The method accepts two parameters, an email and a password.
4141
4242``` javascript
43- firestack .auth . createUserWithEmail (' ari@fullstack.io' , ' 123456' )
43+ firestack .auth (). createUserWithEmailAndPassword (' ari@fullstack.io' , ' 123456' )
4444 .then ((user ) => {
4545 console .log (' user created' , user)
4646 })
@@ -49,13 +49,13 @@ firestack.auth.createUserWithEmail('ari@fullstack.io', '123456')
4949 })
5050```
5151
52- #### [ signInWithEmail ()] ( https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signInWithEmailAndPassword )
52+ #### [ signInWithEmailAndPassword ()] ( https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signInWithEmailAndPassword )
5353
54- To sign a user in with their email and password, use the ` signInWithEmail ()` function.
54+ To sign a user in with their email and password, use the ` signInWithEmailAndPassword ()` function.
5555It accepts two parameters, the user's email and password:
5656
5757``` javascript
58- firestack .auth . signInWithEmail (' ari@fullstack.io' , ' 123456' )
58+ firestack .auth (). signInWithEmailAndPassword (' ari@fullstack.io' , ' 123456' )
5959 .then ((user ) => {
6060 console .log (' User successfully logged in' , user)
6161 })
@@ -69,13 +69,14 @@ firestack.auth.signInWithEmail('ari@fullstack.io', '123456')
6969Sign an anonymous user. If the user has already signed in, that user will be returned.
7070
7171``` javascript
72- firestack .auth .signInAnonymously ()
72+ firestack .auth () .signInAnonymously ()
7373 .then ((user ) => {
7474 console .log (' Anonymous user successfully logged in' , user)
7575 })
7676 .catch ((err ) => {
7777 console .error (' Anonymous user signin error' , err);
7878 })
79+ ```
7980
8081#### signInWithProvider()
8182
@@ -88,7 +89,7 @@ We can use an external authentication provider, such as twitter/facebook for aut
8889To sign a user using a self-signed custom token, use the ` signInWithCustomToken() ` function. It accepts one parameter, the custom token:
8990
9091``` javascript
91- firestack.auth.signInWithCustomToken (TOKEN )
92+ firestack .auth () .signInWithCustomToken (TOKEN )
9293 .then ((user ) => {
9394 console .log (' User successfully logged in' , user)
9495 })
@@ -103,7 +104,7 @@ We can update the current user's email by using the command: `updateUserEmail()`
103104It accepts a single argument: the user's new email:
104105
105106``` javascript
106- firestack .auth .updateUserEmail (' ari+rocks@fullstack.io' )
107+ firestack .auth () .updateUserEmail (' ari+rocks@fullstack.io' )
107108 .then ((res ) => console .log (' Updated user email' ))
108109 .catch (err => console .error (' There was an error updating user email' ))
109110```
@@ -114,7 +115,7 @@ We can update the current user's password using the `updateUserPassword()` metho
114115It accepts a single parameter: the new password for the current user
115116
116117``` javascript
117- firestack .auth .updateUserPassword (' somethingReallyS3cr3t733t' )
118+ firestack .auth () .updateUserPassword (' somethingReallyS3cr3t733t' )
118119 .then (res => console .log (' Updated user password' ))
119120 .catch (err => console .error (' There was an error updating your password' ))
120121```
@@ -128,7 +129,7 @@ It accepts a single parameter:
128129Possible keys are listed [ here] ( https://firebase.google.com/docs/auth/ios/manage-users#update_a_users_profile ) .
129130
130131``` javascript
131- firestack .auth
132+ firestack .auth ()
132133 .updateUserProfile ({
133134 displayName: ' Ari Lerner'
134135 })
@@ -142,7 +143,7 @@ To send a password reset for a user based upon their email, we can call the `sen
142143It accepts a single parameter: the email of the user to send a reset email.
143144
144145``` javascript
145- firestack .auth .sendPasswordResetWithEmail (' ari+rocks@fullstack.io' )
146+ firestack .auth () .sendPasswordResetWithEmail (' ari+rocks@fullstack.io' )
146147 .then (res => console .log (' Check your inbox for further instructions' ))
147148 .catch (err => console .error (' There was an error :(' ))
148149```
@@ -152,7 +153,7 @@ It's possible to delete a user completely from your account on Firebase.
152153Calling the ` deleteUser() ` method will take care of this for you.
153154
154155``` javascript
155- firestack .auth
156+ firestack .auth ()
156157 .deleteUser ()
157158 .then (res => console .log (' Sad to see you go' ))
158159 .catch (err => console .error (' There was an error - Now you are trapped!' ))
@@ -163,7 +164,7 @@ firestack.auth
163164If you want user's token, use ` getToken() ` method.
164165
165166``` javascript
166- firestack .auth
167+ firestack .auth ()
167168 .getToken ()
168169 .then (res => console .log (res .token ))
169170 .catch (err => console .error (' error' ))
@@ -175,7 +176,7 @@ To sign the current user out, use the `signOut()` method.
175176It accepts no parameters
176177
177178``` javascript
178- firestack .auth
179+ firestack .auth ()
179180 .signOut ()
180181 .then (res => console .log (' You have been signed out' ))
181182 .catch (err => console .error (' Uh oh... something weird happened' ))
@@ -188,7 +189,7 @@ Although you _can_ get the current user using the `getCurrentUser()` method, it'
188189However, if you need to get the current user, call the ` getCurrentUser() ` method:
189190
190191``` javascript
191- firestack .auth
192+ firestack .auth ()
192193 .getCurrentUser ()
193194 .then (user => console .log (' The currently logged in user' , user))
194195 .catch (err => console .error (' An error occurred' ))
0 commit comments