/**
 * Register controller
 * @namespace crowdsource.authentication.controllers
 */
(function () {
    'use strict';

    angular
        .module('crowdsource.authentication.controllers')
        .controller('RegisterController', ['$state', '$scope', 'Authentication', '$mdToast',
            function RegisterController($state, $scope, Authentication, $mdToast) {

                activate();
                /**
                 * @name activate
                 * @desc Actions to be performed when this controller is instantiated
                 * @memberOf crowdsource.authentication.controllers.RegisterController
                 */
                function activate() {
                    // If the user is authenticated, they should not be here.
                    if (Authentication.isAuthenticated()) {
                        $state.go('profile');
                    }
                }

                var vm = this;

                vm.register = register;
                vm.errors = [];

                /**
                 * @name register
                 * @desc Register a new user
                 * @memberOf crowdsource.authentication.controllers.RegisterController
                 */
                function register(isValid) {
                    if (isValid) {
                        Authentication.register(vm.email, vm.firstname, vm.lastname,
                            vm.password1, vm.password2).then(function () {

                                $state.go('login');
                                $mdToast.showSimple('Email with an activation link has been sent.');
                            }, function (data, status) {

                                //Global errors
                                if (data.data.hasOwnProperty('detail')) {
                                    vm.error = data.data.detail;
                                    $scope.form.$setPristine();
                                }

                                angular.forEach(data.data, function (errors, field) {

                                    if (field == 'non_field_errors') {
                                        // Global errors
                                        vm.error = errors.join(', ');
                                        $scope.form.$setPristine();
                                    } else {
                                        //Field level errors
                                        $scope.form[field].$setValidity('backend', false);
                                        $scope.form[field].$dirty = true;
                                        vm.errors[field] = errors.join(', ');
                                    }
                                });

                            }).finally(function () {
                            });
                    }
                    vm.submitted = true;
                }
            }]);
})();

@@ -1452,65 +1452,8 @@
 ) %7B%0A
-%0A                                $state.go('login');%0A    
     
@@ -1541,32 +1541,81 @@
 en sent.');%0A    
+                        $state.go('home.login');%0A
                 
@@ -1680,20 +1680,16 @@
         
-    
 //Global
@@ -1688,36 +1688,32 @@
 //Global errors%0A
-    
                 
@@ -1790,36 +1790,32 @@
                 
-    
 vm.error = data.
@@ -1851,36 +1851,32 @@
                 
-    
 $scope.form.$set
@@ -1879,36 +1879,32 @@
 $setPristine();%0A
-    
                 
@@ -1946,20 +1946,16 @@
         
-    
 angular.
@@ -2029,28 +2029,24 @@
             
-    
 if (field ==
@@ -2104,20 +2104,16 @@
         
-   
- 
 // Globa
@@ -2113,36 +2113,32 @@
 / Global errors%0A
-    
                 
@@ -2215,36 +2215,32 @@
                 
-    
 $scope.form.$set
@@ -2283,20 +2283,16 @@
         
-   
- 
 %7D else %7B
@@ -2292,20 +2292,16 @@
  else %7B%0A
-    
         
@@ -2377,36 +2377,32 @@
                 
-    
 $scope.form%5Bfiel
@@ -2464,36 +2464,32 @@
                 
-  
-  
 $scope.form%5Bfiel
@@ -2498,36 +2498,32 @@
 .$dirty = true;%0A
-    
                 
@@ -2604,36 +2604,32 @@
                 
-    
 %7D%0A              
@@ -2646,21 +2646,13 @@
     
- 
-   
 %7D);%0A%0A
-    
     
@@ -2688,36 +2688,32 @@
 y(function () %7B%0A
-    
                 

fix login route after signup