Guest User

Untitled

a guest
Dec 2nd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <form action="" method="post" name="Login_Form" class="form-signin">
  2. <hr class="colorgraph"><br>
  3.  
  4. <input type="text" id="login-username" ng-model="loginEmail" class="form-control" name="username" placeholder="email" autofocus="" />
  5. <input type="password" ng-model="loginPassword" class="form-control" name="password" placeholder="Password"/>
  6.  
  7. <button class="btn btn-lg btn-primary btn-block" name="Submit" value="Login" ng-click="login()" type="Submit">Login</button>
  8. </form>
  9.  
  10. app.controller('loginCtrl', ['$scope', 'FBMSG', 'authFactory', function($scope, FBMSG, authFactory) {
  11.  
  12.  
  13. $scope.login = function () {
  14. var email = $scope.loginEmail;
  15. var password = $scope.loginPassword;
  16.  
  17. var result = authFactory.authUser(email, password);
  18. result.then(function(authData){
  19. console.log("User Successfully logged in with uid: ", authData.uid)
  20. }, function(error) {
  21. console.log("Authentication Failed: ", error)
  22. })
  23. } }]);
  24.  
  25. app.factory('authFactory', ['FBMSG', '$firebase', '$firebaseAuth', function(FBMSG, $firebase, $firebaseAuth) {
  26. var authFactory = {};
  27. var auth = $firebaseAuth();
  28. console.log(auth);
  29.  
  30. authFactory.createUser = function(email, password) {
  31. return auth.$createUser({
  32. email: email,
  33. password: password
  34. })};
  35.  
  36. // Authentication
  37. authFactory.authUser = function(email, password) {
  38. return auth.$signInWithEmailAndPassword({
  39. email: email,
  40. password: password
  41. });
  42. }
  43. return authFactory; }]);
Add Comment
Please, Sign In to add comment