Skip to content

Instantly share code, notes, and snippets.

View Niklas2908's full-sized avatar

Niklas Niklas2908

View GitHub Profile
@shadowcodex
shadowcodex / firebase_firstime_user.js
Created December 7, 2015 23:38
Firebase: Detecting if user exists.This snippet detects if a user ID already exists, in order to do first time user functions.
// Assuming you have included the firebase script tag above this javascript
// For reference here is the tag: <script src="https://cdn.firebase.com/js/client/2.3.2/firebase.js"></script>
// Assumes you have already authenticated the user.
// Setup your firebase reference
var ref = new Firebase('https://your-app.firebaseIO-demo.com/');
// Setup a way to get your userid (Assuming using provided firebase authentication method...)
function getUser(authData) {
@anantn
anantn / firebase_detect_data.js
Created December 18, 2012 00:54
Firebase: Detecting if data exists. This snippet detects if a user ID is already taken
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');