I am creating an angularJS application and planning to implement Firebase for simple authentication.
Within my index.html file, I have added:
<script src="https://cdn.firebase.com/js/simple-login/1.6.2/firebase-simple-login.js"></script>
<script src="scripts/login.js"></script>
This is the current state of my login.js file:
$(document).ready(function(){
var myRef = new Firebase("https://my_app.firebaseio.com");
var auth = new FirebaseSimpleLogin(myRef, function(error, user) {
if (error) {
// an error occurred while attempting login
console.log(error);
} else if (user) {
// authenticated user with Firebase
console.log("User ID: " + user.uid + ", Provider: " + user.provider);
} else {
// user logged out
}
});
var authRef = new Firebase("https://my_app.firebaseio.com/.info/authenticated");
authRef.on("value", function(snap) {
if (snap.val() === true) {
alert("authenticated");
} else {
alert("not authenticated");
}
});
auth.login('password', {
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d686e786f5d75">[email protected]</a>',
password: 'password',
});
console.log(auth);
});
My main goal with this code is to test the login functionality and examine the structure of the auth object post-login.
Future implementation involves integrating the login process into an ng-model to pass the data dynamically rather than hardcoded.
The issue currently encountered is that the code fails to execute, yielding an error in the JavaScript console:
Uncaught ReferenceError: Firebase is not defined
What could be causing this problem?