'use strict';

angular.module('secondlead.common')
  .factory('Auth', function ($firebaseAuth, ENDPOINT_URI) {
    var ref = new Firebase(ENDPOINT_URI);
    return $firebaseAuth(ref);
  })
;
@@ -30,17 +30,17 @@
 ('second
-l
+L
 ead.comm
@@ -75,49 +75,343 @@
 tion
- 
 ($
-firebaseAuth, ENDPOINT_URI
+http, LocalService, AccessLevels) %7B%0A%09return %7B%0A%09  authorize: function(access) %7B%0A%09    if (access === AccessLevels.user) %7B%0A%09      return this.isAuthenticated();%0A%09    %7D else %7B%0A%09      return true;%0A%09    %7D%0A%09  %7D,%0A%0A%09  isAuthenticated: function() %7B%0A%09    return LocalService.get('auth_token');%0A%09  %7D,%0A%0A%09  login: function(credentials
 ) %7B%0A
+%09
     var 
 ref 
@@ -410,75 +410,636 @@
 var 
-ref = new Firebase(ENDPOINT_URI
+login = $http.post('/auth/authenticate', credentials);%0A%09    login.success(function(result) %7B%0A%09      LocalService.set('auth_token', JSON.stringify(result));%0A%09    %7D);%0A%09    return login;%0A%09  %7D,%0A%0A%09  logout: function() %7B%0A%09    // The backend doesn't care about logouts, delete the token and you're good to go.%0A%09    LocalService.unset('auth_token'
 );%0A
+%09
   
-  return $firebaseAuth(ref
+%7D,%0A%0A%09  register: function(formData) %7B%0A%09    LocalService.unset('auth_token');%0A%09    var register = $http.post('/auth/register', formData);%0A%09    register.success(function(result) %7B%0A%09      LocalService.set('auth_token', JSON.stringify(result)
 );%0A
+%09 
   
+ 
 %7D)
-%0A
+;%0A%09    return register;%0A%09  %7D%0A%0A%09%7D;%0A  %7D)
 ;

Refactor auth service