Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions app/modules/adhocracyEmbedder/services/adhocracy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions app/modules/auth/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ auth.config(function ($routeProvider) {
})
.when('/register', {
template: '<register></register>'
})
.when('/password_reset',{
template: '<password-reset></password-reset>'
});
});
37 changes: 33 additions & 4 deletions app/modules/auth/controllers/authControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};
}
])
10 changes: 8 additions & 2 deletions app/modules/auth/directives/loginRegister.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion app/modules/auth/partials/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ <h4>
<p>Use your created account to login.</p>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<form ng-controller="LoginController" name="loginForm" novalidate>
Expand All @@ -31,6 +30,9 @@ <h4>
<div class="form-group">
<input type="submit" name="submit" class="btn btn-primary" ng-disabled="!loginForm.$valid" ng-click="login()" value="Login" />
</div>
<div class="form-group">
<a href ng-click="goToPasswordReset()">Forgot your password?</a>
</div>
</form>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion app/modules/auth/partials/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ <h4>
<div class="fonticon fonticon-close" ng-click="help=!help"></div>
<p>Create an account to login.</p>
</div>
</div>
</div>
<div class="row" ng-controller="RegisterController">
<div class="col-sm-4 col-sm-offset-4" >
Expand Down
7 changes: 7 additions & 0 deletions app/modules/auth/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down