-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnsigned.js
66 lines (45 loc) · 1.53 KB
/
Unsigned.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React, { Component } from 'react';
import firebase from './lib/fire'
var db = firebase.database();
var authFire = firebase.auth();
class Unsigned extends Component {
login() {
var provider = new firebase.auth.GoogleAuthProvider();
//signInwithPopup retuurns a promise that either it will fail or succeeed and depending upon that if succeeds then.then is called elese
//.catch is called
authFire.signInWithPopup(provider)
.then(function(result) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
console.log(token +" "+ user);
console.log(user);
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
}
render() {
return (
<div className="#d1c4e9 deep-purple lighten-4">
<h1>Hello everyone.</h1>
<br />
<h3>Welcome to the basic chatting application.</h3>
<br />
<br />
<h4>You are seeing this page because you are not signedin. </h4>
<br />
<center><button className="btn" align="center" onClick={()=>{this.login();}}>login</button></center>
</div>
);
}
}
export default Unsigned;