An angular module for user authentication to the Firebase email & password authentication service.
Angular module name: lfFirebaseAuth
Name of service: lfFirebaseAuthService
Important: Calling module must declare a constant string named FIREBASE_URL containing the url of a firebase database.
- add - creates a new user
- authServiceError - returns an object with details of the last error occurred
- changePassword - changes a user password
- isLoggedIn - returns true if user is logged in, returns false otherwise
- isTemporaryPassword - returns true if user logged in with a temporary password. returns false otherwise
- login - signs in an existing user
- logout - logs out current user
- resetPassword - Creates a temporary password and generates email to user for resetting current password
- user - returns an object containing user properties
First include the javascript file in your html document:
<script src="./lf-firebase-auth/lf-firebase-auth-service.js"></script>
Then use in your own javascript file. Example shown below:
var myApp = angular.module('myApp', ['lfFirebaseAuth']);
myApp.constant('FIREBASE_URL', 'https://mydb.firebaseio.com'); // Needed by the auth service!!!
myApp.controller('MyController', ['lfFirebaseAuthService', function(lfFirebaseAuthService) {
var self = this;
self.createUser = function() {
lfFirebaseAuthService.add({email:'[email protected]', password:'12345678', name: 'john doe'}, true).then(function(){
self.userServiceError = {};
$location.path('/#/');
}, function(error) {
self.userServiceError = error;
});
};
});