Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit 388948c

Browse files
committed
Fixes #2: Barebones chat example w/ anonymous auth
1 parent cd8d10e commit 388948c

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

examples/anonymous_auth.html

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
6+
<script src="https://cdn.firebase.com/v0/firebase-simple-login.js"></script>
7+
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
8+
9+
<!-- Download from https://github.com/firebase/Firechat -->
10+
<link rel="stylesheet" href="../dist/0.1.3/firechat-default.min.css" />
11+
<script src="../dist/0.1.3/firechat-default.min.js"></script>
12+
<style>
13+
#firechat-wrapper {
14+
height: 475px;
15+
max-width: 325px;
16+
padding: 10px;
17+
border: 1px solid #ccc;
18+
background-color: #fff;
19+
margin: 50px auto;
20+
text-align: center;
21+
-webkit-border-radius: 4px;
22+
-moz-border-radius: 4px;
23+
border-radius: 4px;
24+
-webkit-box-shadow: 0 5px 25px #666;
25+
-moz-box-shadow: 0 5px 25px #666;
26+
box-shadow: 0 5px 25px #666;
27+
}
28+
</style>
29+
</head>
30+
31+
<!--
32+
Example: Anonymous Authentication
33+
34+
This example uses Firebase Simple Login to create 'anonymous' user sessions in Firebase,
35+
meaning that user credentials are not required, though a user has a valid Firebase
36+
authentication token and security rules still apply.
37+
38+
Requirements: in order to use this example with your own Firebase, you'll need to do the following:
39+
1. Apply the security rules at https://github.com/firebase/firechat/blob/master/rules.json
40+
2. Enable the 'Anonymous' authentication provider in Forge
41+
3. Update the URL below to reference your Firebase
42+
4. Update the room id for auto-entry with a public room you have created
43+
-->
44+
<body>
45+
<div id="firechat-wrapper"></div>
46+
<script type='text/javascript'>
47+
var chatRef = new Firebase('https://firechat-demo.firebaseio.com');
48+
var chat = new FirechatUI(chatRef, document.getElementById("firechat-wrapper"));
49+
var simpleLogin = new FirebaseSimpleLogin(chatRef, function(err, user) {
50+
if (user) {
51+
chat.setUser(user.id, 'Anonymous' + user.id.substr(0, 8));
52+
setTimeout(function() {
53+
chat._chat.enterRoom('-Iy1N3xs4kN8iALHV0QA');
54+
}, 500);
55+
} else {
56+
simpleLogin.login('anonymous');
57+
}
58+
});
59+
</script>
60+
</body>
61+
</html>

0 commit comments

Comments
 (0)