Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <button type="button" class="btn btn-info" ng-click="openModal('md')">E-mail & password</button>
- $scope.openModal = function(size) {
- var modalInstance = $uibModal.open({
- templateUrl: 'javascript/templates/emailLoginModalContent.html',
- controller: 'EmailLoginModalInstanceCtrl',
- scope: $scope,
- size: size
- });
- };
- app.controller('EmailLoginModalInstanceCtrl', ['$scope', '$uibModalInstance', '$firebaseAuth', function($scope, $uibModalInstance, $firebaseAuth) {
- console.log("EmailLoginModalInstanceCtrl controller.");
- var ref = new Firebase("https://my-firebase.firebaseio.com/");
- $scope.authObj = $firebaseAuth(ref);
- // Login user
- $scope.loginUser = function(user) {
- ref.authWithPassword({
- email: $scope.user.email,
- password: $scope.user.password
- }, function(error, authData) {
- if (error) {
- console.log("Login Failed!", error);
- } else {
- console.log("Authenticated successfully with payload:", authData);
- $scope.authData = authData;
- $scope.authData.uid = authData.uid;
- console.log($scope.authData.uid);
- $scope.reset();
- $scope.cancel();
- $scope.$apply(function() {
- console.log("Applied!");
- });
- }
- });
- };
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement