fixed errors for password reset, user signup and user signin
This commit is contained in:
parent
34b2cba461
commit
a829e08d73
@ -122,12 +122,6 @@ exports.signup = function(req, res) {
|
||||
// Add missing user fields
|
||||
user.provider = 'local';
|
||||
|
||||
if(req.body.password.length < 4){
|
||||
return res.status(400).send({
|
||||
message: 'Password must be at least 4 characters long'
|
||||
});
|
||||
}
|
||||
|
||||
// Then save the temporary user
|
||||
nev.createTempUser(user, function (err, existingPersistentUser, newTempUser) {
|
||||
if (err) {
|
||||
@ -167,13 +161,7 @@ exports.signup = function(req, res) {
|
||||
* Signin after passport authentication
|
||||
*/
|
||||
exports.signin = function(req, res, next) {
|
||||
console.log(req.body);
|
||||
if(req.body.password.length < 4){
|
||||
return res.status(400).send({
|
||||
message: 'Password must be at least 4 characters long'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
passport.authenticate('local', function(err, user, info) {
|
||||
if (err || !user) {
|
||||
res.status(400).send(info);
|
||||
|
@ -37,13 +37,6 @@ var validateLocalStrategyProperty = function(property) {
|
||||
return ((this.provider !== 'local' && !this.updated) || propHasLength);
|
||||
};
|
||||
|
||||
/**
|
||||
* A Validation function for local strategy password
|
||||
*/
|
||||
var validateLocalStrategyPassword = function(password) {
|
||||
return (this.provider !== 'local' || (password && password.length > 6));
|
||||
};
|
||||
|
||||
/**
|
||||
* A Validation function for username
|
||||
*/
|
||||
|
@ -438,11 +438,11 @@ section.public-form .btn {
|
||||
}
|
||||
|
||||
/*CREATE-NEW FORM MODAL*/
|
||||
.form-item.create-new.new-form {
|
||||
.form-item.new-form {
|
||||
background-color: rgb(300,131,131);
|
||||
z-index: 11;
|
||||
}
|
||||
.form-item.create-new.new-form:hover {
|
||||
.form-item.new-form:hover {
|
||||
background-color: rgb(300,100,100);
|
||||
}
|
||||
.form-item.new-form input[type='text'] {
|
||||
|
@ -28,7 +28,7 @@
|
||||
<section class="container">
|
||||
<br>
|
||||
<div class="row">
|
||||
<div ng-click="openCreateModal()" class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item create-new">
|
||||
<div ng-click="openCreateModal()" class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item new-button create-new">
|
||||
<div class="title-row col-xs-12">
|
||||
<h4 class="fa fa-plus fa-6"></h4>
|
||||
</div>
|
||||
|
@ -310,12 +310,12 @@ section.public-form field-directive .btn[disabled]{
|
||||
}
|
||||
|
||||
/*CREATE-NEW FORM MODAL*/
|
||||
.form-item.create-new.new-form {
|
||||
.form-item.new-form {
|
||||
background-color: #832383;
|
||||
background-color: rgb(300,131,131);
|
||||
z-index: 11;
|
||||
}
|
||||
.form-item.create-new.new-form:hover {
|
||||
.form-item.new-form:hover {
|
||||
background-color: #3079b5;
|
||||
}
|
||||
.form-item.new-form input[type='text'] {
|
||||
@ -398,19 +398,23 @@ h3.forms-list-title {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.form-item.create-new .title-row{
|
||||
.form-item.create-new .title-row {
|
||||
padding: 0;
|
||||
}
|
||||
.form-item.create-new .title-row h4 {
|
||||
font-size: 7em;
|
||||
}
|
||||
|
||||
.form-item .details-row{
|
||||
margin-top: 3.2em;
|
||||
.form-item.create-new.new-button .details-row {
|
||||
padding-top: 20%;
|
||||
}
|
||||
.form-item .details-row small {
|
||||
.form-item .details-row small {
|
||||
font-size: 0.6em;
|
||||
}
|
||||
.form-item.create-new .details-row small {
|
||||
.form-item.create-new .details-row small {
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
.form-item.create-new input {
|
||||
max-width: 100%
|
||||
}
|
||||
|
@ -7,29 +7,30 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
|
||||
$scope = $rootScope;
|
||||
$scope.credentials = {};
|
||||
$scope.error = '';
|
||||
$scope.forms = [];
|
||||
$scope.forms = {};
|
||||
|
||||
$scope.signin = function() {
|
||||
console.log($scope.forms.signinForm);
|
||||
User.login($scope.credentials).then(
|
||||
function(response) {
|
||||
Auth.login(response);
|
||||
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
|
||||
if(!$scope.forms.signinForm.$invalid){
|
||||
User.login($scope.credentials).then(
|
||||
function(response) {
|
||||
Auth.login(response);
|
||||
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
|
||||
|
||||
if($state.previous.name !== 'home' && $state.previous.name !== 'verify' && $state.previous.name !== '') {
|
||||
$state.go($state.previous.name);
|
||||
} else {
|
||||
$state.go('listForms');
|
||||
if($state.previous.name !== 'home' && $state.previous.name !== 'verify' && $state.previous.name !== '') {
|
||||
$state.go($state.previous.name);
|
||||
} else {
|
||||
$state.go('listForms');
|
||||
}
|
||||
},
|
||||
function(error) {
|
||||
$rootScope.user = Auth.ensureHasCurrentUser(User);
|
||||
$scope.user = $rootScope.user;
|
||||
|
||||
$scope.error = error;
|
||||
console.error('loginError: '+error);
|
||||
}
|
||||
},
|
||||
function(error) {
|
||||
$rootScope.user = Auth.ensureHasCurrentUser(User);
|
||||
$scope.user = $rootScope.user;
|
||||
|
||||
$scope.error = error;
|
||||
console.error('loginError: '+error);
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.signup = function() {
|
||||
@ -38,20 +39,22 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
|
||||
return;
|
||||
}
|
||||
|
||||
User.signup($scope.credentials).then(
|
||||
function(response) {
|
||||
$state.go('signup-success');
|
||||
},
|
||||
function(error) {
|
||||
console.error(error);
|
||||
if(error) {
|
||||
$scope.error = error;
|
||||
console.error(error);
|
||||
} else {
|
||||
console.error('No response received');
|
||||
}
|
||||
}
|
||||
);
|
||||
if(!$scope.forms.signupForm.$invalid){
|
||||
User.signup($scope.credentials).then(
|
||||
function(response) {
|
||||
$state.go('signup-success');
|
||||
},
|
||||
function(error) {
|
||||
console.error(error);
|
||||
if(error) {
|
||||
$scope.error = error;
|
||||
console.error(error);
|
||||
} else {
|
||||
console.error('No response received');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ angular.module('users').controller('PasswordController', ['$scope', '$stateParam
|
||||
$translate.use($window.locale);
|
||||
|
||||
$scope.error = '';
|
||||
$scope.forms = {};
|
||||
|
||||
// Submit forgotten password account id
|
||||
$scope.askForPasswordReset = function() {
|
||||
@ -24,24 +25,25 @@ angular.module('users').controller('PasswordController', ['$scope', '$stateParam
|
||||
|
||||
// Change user password
|
||||
$scope.resetUserPassword = function() {
|
||||
$scope.success = $scope.error = null;
|
||||
User.resetPassword($scope.passwordDetails, $stateParams.token).then(
|
||||
function(response){
|
||||
console.log(response.message);
|
||||
// If successful show success message and clear form
|
||||
$scope.success = response.message;
|
||||
$scope.error = null;
|
||||
$scope.passwordDetails = null;
|
||||
if(!$scope.forms.resetPasswordForm.$invalid){
|
||||
$scope.success = $scope.error = null;
|
||||
User.resetPassword($scope.passwordDetails, $stateParams.token).then(
|
||||
function(response){
|
||||
// If successful show success message and clear form
|
||||
$scope.success = response.message;
|
||||
$scope.error = null;
|
||||
$scope.passwordDetails = null;
|
||||
|
||||
// And redirect to the index page
|
||||
$state.go('reset-success');
|
||||
},
|
||||
function(error){
|
||||
$scope.error = error.message || error;
|
||||
$scope.success = null;
|
||||
$scope.passwordDetails = null;
|
||||
}
|
||||
);
|
||||
// And redirect to the index page
|
||||
$state.go('reset-success');
|
||||
},
|
||||
function(error){
|
||||
$scope.error = error.message || error;
|
||||
$scope.success = null;
|
||||
$scope.passwordDetails = null;
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
@ -4,7 +4,7 @@
|
||||
<img src="/static/modules/core/img/logo_white.svg" height="100px">
|
||||
</div>
|
||||
<div class="col-xs-offset-3 col-xs-6 col-sm-offset-4 col-sm-4">
|
||||
<form name="userForm" data-ng-submit="signup()" class="signin form-horizontal" autocomplete="off">
|
||||
<form name="forms.signupForm" data-ng-submit="signup()" class="signin form-horizontal" autocomplete="off">
|
||||
<fieldset>
|
||||
<div data-ng-show="error" id="signup_errors" class="text-center">
|
||||
{{'SIGNUP_ERROR_TEXT' | translate}}: <br>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<section class="row auth" data-ng-controller="PasswordController">
|
||||
<h3 class="col-md-12 text-center">{{ 'RESET_PASSWORD' | translate }}</h3>
|
||||
<div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6">
|
||||
<form data-ng-submit="resetUserPassword()" class="signin form-horizontal" autocomplete="off">
|
||||
<form name="forms.resetPasswordForm" data-ng-submit="resetUserPassword()" class="signin form-horizontal" autocomplete="off">
|
||||
<fieldset>
|
||||
<div ng-if="error" class="text-center text-danger">
|
||||
<strong>{{error}}</strong>
|
||||
|
Loading…
Reference in New Issue
Block a user