diff --git a/app/modules/adhocracyEmbedder/services/adhocracy.js b/app/modules/adhocracyEmbedder/services/adhocracy.js
index 0a36f88b..7a539586 100644
--- a/app/modules/adhocracyEmbedder/services/adhocracy.js
+++ b/app/modules/adhocracyEmbedder/services/adhocracy.js
@@ -99,7 +99,7 @@ angular.module('pcApp.adhocracyEmbedder.services.adhocracy', [])
for (errorIndex in serverErrors) {
if (serverErrors.hasOwnProperty(errorIndex)) {
var error = serverErrors[errorIndex];
- if (error.location = 'body') {
+ if (error.location === 'body') {
simpleName = error.name.split('.').pop();
processedErrors[simpleName] = error.description;
}
@@ -195,7 +195,18 @@ angular.module('pcApp.adhocracyEmbedder.services.adhocracy', [])
},
transformResponse: withResponseErrorTransformer()
})
- }
+ };
+
+ client.resetPassword = function(email) {
+ return $http({
+ method: 'POST',
+ url: url('/create_password_reset/'),
+ data: {
+ email: email
+ },
+ transformResponse: withResponseErrorTransformer()
+ });
+ };
return client;
}
diff --git a/app/modules/auth/auth.js b/app/modules/auth/auth.js
index 3bd33576..37507cef 100644
--- a/app/modules/auth/auth.js
+++ b/app/modules/auth/auth.js
@@ -11,5 +11,8 @@ auth.config(function ($routeProvider) {
})
.when('/register', {
template: ''
+ })
+ .when('/password_reset',{
+ template: ''
});
});
diff --git a/app/modules/auth/controllers/authControllers.js b/app/modules/auth/controllers/authControllers.js
index 65b365af..25b53fbb 100644
--- a/app/modules/auth/controllers/authControllers.js
+++ b/app/modules/auth/controllers/authControllers.js
@@ -42,8 +42,8 @@ angular.module('pcApp.auth.controllers.authControllers', [
])
.controller('LoginController', [
'$scope', '$location', 'Auth', function ($scope, $location, Auth) {
- $scope.goToRegister = function ( path ) {
- $location.path('/register');
+ $scope.goToPasswordReset = function ( path ) {
+ $location.path('/password_reset');
};
$scope.$submitted = false;
@@ -68,7 +68,36 @@ angular.module('pcApp.auth.controllers.authControllers', [
$scope.serverErrors.$other = 'Unknown error.';
throw e;
}
- })
+ });
};
}
- ]);
+ ])
+ .controller('ResetPasswordController', [
+ '$scope', 'Auth', function ($scope, Auth) {
+ $scope.$submitted = false;
+ $scope.serverErrors = {}
+ $scope.completed = false;
+
+ $scope.resetPassword = function () {
+ $scope.$submitted = true;
+
+ if (!$scope.resetPasswordForm.$valid) {
+ return false
+ }
+
+ Auth.resetPassword($scope.email)
+ .then(function () {
+ $scope.completed = true;
+ }).catch(function (response) {
+ try {
+ $scope.serverErrors = response.data.errorDict;
+ } catch (e) {
+ $scope.serverErrors.$other = 'Unknown error.';
+ throw e;
+ }
+ });
+
+ return true;
+ };
+ }
+ ])
diff --git a/app/modules/auth/directives/loginRegister.js b/app/modules/auth/directives/loginRegister.js
index e9d9302e..b9f9aeaf 100644
--- a/app/modules/auth/directives/loginRegister.js
+++ b/app/modules/auth/directives/loginRegister.js
@@ -5,13 +5,19 @@ angular.module('pcApp.auth.directives.loginRegister', [
.directive('login', function () {
return {
restrict: 'E',
- templateUrl: 'modules/auth/partials/login.html',
+ templateUrl: 'modules/auth/partials/login.html'
};
})
.directive('register', function () {
return {
restrict: 'E',
- templateUrl: 'modules/auth/partials/register.html',
+ templateUrl: 'modules/auth/partials/register.html'
+ };
+ })
+ .directive('passwordReset', function () {
+ return {
+ restrict: 'E',
+ templateUrl: 'modules/auth/partials/passwordReset.html'
};
})
.directive("passwordVerify", function() {
diff --git a/app/modules/auth/partials/login.html b/app/modules/auth/partials/login.html
index cffeefe6..044c1504 100644
--- a/app/modules/auth/partials/login.html
+++ b/app/modules/auth/partials/login.html
@@ -12,7 +12,6 @@
Use your created account to login.
-
diff --git a/app/modules/auth/partials/register.html b/app/modules/auth/partials/register.html
index 4a977fd0..3fcb5ec7 100644
--- a/app/modules/auth/partials/register.html
+++ b/app/modules/auth/partials/register.html
@@ -11,7 +11,6 @@
Create an account to login.
-
diff --git a/app/modules/auth/services/auth.js b/app/modules/auth/services/auth.js
index a93e2937..fc56d495 100644
--- a/app/modules/auth/services/auth.js
+++ b/app/modules/auth/services/auth.js
@@ -148,6 +148,13 @@ angular.module('pcApp.auth.services.auth', [
return AdhocracyClient.register(name, email, password)
};
+ /** Wrapper to make A3 auth features pluggable. Calls directly A3
+ * specific password reset code.
+ */
+ Auth.resetPassword = function (email) {
+ return AdhocracyClient.resetPassword(email);
+ };
+
Auth.logout = function () {
teardownSession();
};