Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="" method="post" name="Login_Form" class="form-signin">
- <hr class="colorgraph"><br>
- <input type="text" id="login-username" ng-model="loginEmail" class="form-control" name="username" placeholder="email" autofocus="" />
- <input type="password" ng-model="loginPassword" class="form-control" name="password" placeholder="Password"/>
- <button class="btn btn-lg btn-primary btn-block" name="Submit" value="Login" ng-click="login()" type="Submit">Login</button>
- </form>
- app.controller('loginCtrl', ['$scope', 'FBMSG', 'authFactory', function($scope, FBMSG, authFactory) {
- $scope.login = function () {
- var email = $scope.loginEmail;
- var password = $scope.loginPassword;
- var result = authFactory.authUser(email, password);
- result.then(function(authData){
- console.log("User Successfully logged in with uid: ", authData.uid)
- }, function(error) {
- console.log("Authentication Failed: ", error)
- })
- } }]);
- app.factory('authFactory', ['FBMSG', '$firebase', '$firebaseAuth', function(FBMSG, $firebase, $firebaseAuth) {
- var authFactory = {};
- var auth = $firebaseAuth();
- console.log(auth);
- authFactory.createUser = function(email, password) {
- return auth.$createUser({
- email: email,
- password: password
- })};
- // Authentication
- authFactory.authUser = function(email, password) {
- return auth.$signInWithEmailAndPassword({
- email: email,
- password: password
- });
- }
- return authFactory; }]);
Add Comment
Please, Sign In to add comment