Skip to content

Commit 247eb5e

Browse files
committed
Updated to v3
1 parent 098e16c commit 247eb5e

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

app/views/Authentication/Demos/Email.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff 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() {

app/views/Authentication/Demos/ErrorHandling.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)