WIP Domain listing app with automatic status checking. Buitl with AngularJS.

signin.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. /**
  3. * @ngdoc function
  4. * @name domainManagerApp.controller:MainCtrl
  5. * @description
  6. * # MainCtrl
  7. * Controller of the domainManagerApp
  8. */
  9. angular.module('domainManagerApp.signin', ['firebase', 'angular-ladda'])
  10. .controller('SignInController', ['$scope', '$firebaseAuth', '$timeout', function ($scope, $firebaseAuth, $timeout) {
  11. $scope.loading = false;
  12. var firebaseObj = new Firebase("https://j1x-cpanel.firebaseio.com");
  13. $scope.authObj = $firebaseAuth(firebaseObj);
  14. $scope.SignIn = function(event) {
  15. $scope.loading = true;
  16. event.preventDefault(); // To prevent form refresh
  17. var username = $scope.user.email;
  18. var password = $scope.user.password;
  19. $scope.authObj.$authWithPassword({
  20. email: username,
  21. password: password
  22. }).then(function(authData) {
  23. console.log("Logged in as:", authData.uid);
  24. $timeout(function() {
  25. $scope.loading = false; // stop loading
  26. }, 1000);
  27. }).catch(function(error) {
  28. console.error("Authentication failed:", error);
  29. $timeout(function() {
  30. $scope.loading = false; // stop loading
  31. }, 1000);
  32. });
  33. }
  34. }]);