Squashed 'seatmap-webapi/' content from commit 02d4bf7
git-subtree-dir: seatmap-webapi git-subtree-split: 02d4bf7404b8fcb788502ca45c813946b6c4f5b9
This commit is contained in:
97
examples/clients/firebase/vanilla-success.html
Normal file
97
examples/clients/firebase/vanilla-success.html
Normal file
@@ -0,0 +1,97 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Success</title>
|
||||
|
||||
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-auth.js"></script>
|
||||
|
||||
<script>
|
||||
// Your web app's Firebase configuration
|
||||
var firebaseConfig = {
|
||||
apiKey: "",
|
||||
authDomain: "",
|
||||
databaseURL: "",
|
||||
projectId: "",
|
||||
storageBucket: "",
|
||||
messagingSenderId: "",
|
||||
appId: ""
|
||||
};
|
||||
// Initialize Firebase
|
||||
firebase.initializeApp(firebaseConfig);
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var url = '/api.php/records/posts?join=categories&join=tags&join=comments&filter=id,eq,1';
|
||||
|
||||
function requestAPI(accessToken) {
|
||||
var req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function () {
|
||||
if (req.readyState == 4) {
|
||||
try {
|
||||
document.getElementById('output').innerHTML = JSON.stringify(JSON.parse(req.responseText),
|
||||
undefined, 4);
|
||||
} catch (error) {
|
||||
document.getElementById('output').innerHTML = req.responseText;
|
||||
}
|
||||
}
|
||||
}
|
||||
req.open("GET", url, true);
|
||||
req.setRequestHeader('X-Authorization', 'Bearer ' + accessToken);
|
||||
req.send();
|
||||
}
|
||||
|
||||
function initApp() {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
// User is signed in.
|
||||
var displayName = user.displayName;
|
||||
var email = user.email;
|
||||
var emailVerified = user.emailVerified;
|
||||
var photoURL = user.photoURL;
|
||||
var uid = user.uid;
|
||||
var phoneNumber = user.phoneNumber;
|
||||
var providerData = user.providerData;
|
||||
user.getIdToken().then(function (accessToken) {
|
||||
document.getElementById('sign-in-status').textContent = 'Signed in';
|
||||
document.getElementById('account-details').textContent = JSON.stringify({
|
||||
displayName: displayName,
|
||||
email: email,
|
||||
emailVerified: emailVerified,
|
||||
phoneNumber: phoneNumber,
|
||||
photoURL: photoURL,
|
||||
uid: uid,
|
||||
accessToken: accessToken,
|
||||
providerData: providerData
|
||||
}, undefined, 4);
|
||||
|
||||
requestAPI(accessToken)
|
||||
});
|
||||
} else {
|
||||
// User is signed out.
|
||||
document.getElementById('sign-in-status').textContent = 'Signed out';
|
||||
document.getElementById('account-details').textContent = 'null';
|
||||
}
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
};
|
||||
|
||||
window.addEventListener('load', initApp);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Firebase Login Success (or not)</h1>
|
||||
|
||||
<div id="sign-in-status"></div>
|
||||
<pre id="account-details"></pre>
|
||||
|
||||
<pre id="output"></pre>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
68
examples/clients/firebase/vanilla.html
Normal file
68
examples/clients/firebase/vanilla.html
Normal file
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>
|
||||
Firebase
|
||||
</title>
|
||||
|
||||
<!-- The core Firebase JS SDK is always required and must be listed first -->
|
||||
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-auth.js"></script>
|
||||
|
||||
<script>
|
||||
// Your web app's Firebase configuration
|
||||
var firebaseConfig = {
|
||||
apiKey: "",
|
||||
authDomain: "",
|
||||
databaseURL: "",
|
||||
projectId: "",
|
||||
storageBucket: "",
|
||||
messagingSenderId: "",
|
||||
appId: ""
|
||||
};
|
||||
// Initialize Firebase
|
||||
firebase.initializeApp(firebaseConfig);
|
||||
</script>
|
||||
|
||||
<script src="https://cdn.firebase.com/libs/firebaseui/4.0.0/firebaseui.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/4.0.0/firebaseui.css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
// FirebaseUI config.
|
||||
var uiConfig = {
|
||||
signInSuccessUrl: './vanilla-success.html',
|
||||
signInOptions: [
|
||||
// Leave the lines as is for the providers you want to offer your users.
|
||||
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
|
||||
firebase.auth.FacebookAuthProvider.PROVIDER_ID,
|
||||
firebase.auth.TwitterAuthProvider.PROVIDER_ID,
|
||||
firebase.auth.GithubAuthProvider.PROVIDER_ID,
|
||||
firebase.auth.EmailAuthProvider.PROVIDER_ID,
|
||||
firebase.auth.PhoneAuthProvider.PROVIDER_ID,
|
||||
firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID
|
||||
],
|
||||
// tosUrl and privacyPolicyUrl accept either url string or a callback
|
||||
// function.
|
||||
// Terms of service url/callback.
|
||||
tosUrl: '<your-tos-url>',
|
||||
// Privacy policy url/callback.
|
||||
privacyPolicyUrl: function() {
|
||||
window.location.assign('<your-privacy-policy-url>');
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize the FirebaseUI Widget using Firebase.
|
||||
var ui = new firebaseui.auth.AuthUI(firebase.auth());
|
||||
// The start method will wait until the DOM is loaded.
|
||||
ui.start('#firebaseui-auth-container', uiConfig);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Firebase login</h1>
|
||||
|
||||
<div id="firebaseui-auth-container"></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user