File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
app/views/Authentication/Demos Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,12 @@ export class Email extends React.Component {
2828 componentWillMount ( ) {
2929 const { firestack} = this . props ;
3030
31- firestack . auth . listenForAuth ( ( u ) => {
32- console . log ( 'listenForAuth -> ' , u ) ;
31+ this . unsubscribe = firebase . auth ( ) . onAuthStateChanged ( function ( user ) {
32+ console . log ( 'auth state changed ' , user ) ;
3333 } ) ;
34+ // firestack.auth.listenForAuth((u) => {
35+ // console.log('listenForAuth ->', u);
36+ // });
3437 }
3538
3639 fillInFields ( ) {
@@ -44,7 +47,7 @@ export class Email extends React.Component {
4447 const { firestack} = this . props ;
4548 const { email, password } = this . state ;
4649
47- firestack . auth . signInWithEmail ( email , password )
50+ firestack . auth ( ) . signInWithEmailAndPassword ( email , password )
4851 . then ( u => {
4952 console . log ( 'Signed in!' , u ) ;
5053 this . setState ( {
@@ -69,7 +72,9 @@ export class Email extends React.Component {
6972
7073 componentWillUnmount ( ) {
7174 const { firestack} = this . props ;
72- firestack . auth . unlistenForAuth ( ) ;
75+ if ( this . unsubscribe ) {
76+ this . unsubscribe ( ) ;
77+ }
7378 }
7479
7580 render ( ) {
Original file line number Diff line number Diff line change @@ -26,15 +26,18 @@ export class ErrorHandling extends React.Component {
2626
2727 componentWillMount ( ) {
2828 const { firestack} = this . props ;
29- firestack . auth . listenForAuth ( ( user ) => {
30- console . log ( 'user --> ' , user ) ;
29+ this . unsubscribe = firebase . auth ( ) . onAuthStateChanged ( function ( user ) {
30+ console . log ( 'auth state changed ' , user ) ;
3131 } ) ;
3232 }
3333
3434
3535 componentWillUnmount ( ) {
3636 const { firestack} = this . props ;
3737 firestack . auth . unlistenForAuth ( ) ;
38+ if ( this . unsubscribe ) {
39+ this . unsubscribe ( ) ;
40+ }
3841 }
3942
4043 generateError ( key ) {
@@ -43,7 +46,7 @@ export class ErrorHandling extends React.Component {
4346 return ( ) => {
4447 switch ( key ) {
4548 case ERRORS [ 'badUsernamePassword' ] :
46- firestack . auth . signInWithEmail ( 'ari@fullstack.io' , 'definitely_not_my_password' )
49+ firestack . auth ( ) . signInWithEmailAndPassword ( 'ari@fullstack.io' , 'definitely_not_my_password' )
4750 . then ( user => console . log ( 'Success' ) )
4851 . catch ( err => {
4952 console . log ( 'Error with signInWithEmail' , err ) ;
You can’t perform that action at this time.
0 commit comments