fixed errors for password reset, user signup and user signin

This commit is contained in:
David Baldwynn 2017-10-27 23:54:55 -07:00
parent 34b2cba461
commit a829e08d73
9 changed files with 72 additions and 82 deletions

View file

@ -122,12 +122,6 @@ exports.signup = function(req, res) {
// Add missing user fields // Add missing user fields
user.provider = 'local'; 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 // Then save the temporary user
nev.createTempUser(user, function (err, existingPersistentUser, newTempUser) { nev.createTempUser(user, function (err, existingPersistentUser, newTempUser) {
if (err) { if (err) {
@ -167,13 +161,7 @@ exports.signup = function(req, res) {
* Signin after passport authentication * Signin after passport authentication
*/ */
exports.signin = function(req, res, next) { 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) { passport.authenticate('local', function(err, user, info) {
if (err || !user) { if (err || !user) {
res.status(400).send(info); res.status(400).send(info);

View file

@ -37,13 +37,6 @@ var validateLocalStrategyProperty = function(property) {
return ((this.provider !== 'local' && !this.updated) || propHasLength); 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 * A Validation function for username
*/ */

View file

@ -438,11 +438,11 @@ section.public-form .btn {
} }
/*CREATE-NEW FORM MODAL*/ /*CREATE-NEW FORM MODAL*/
.form-item.create-new.new-form { .form-item.new-form {
background-color: rgb(300,131,131); background-color: rgb(300,131,131);
z-index: 11; z-index: 11;
} }
.form-item.create-new.new-form:hover { .form-item.new-form:hover {
background-color: rgb(300,100,100); background-color: rgb(300,100,100);
} }
.form-item.new-form input[type='text'] { .form-item.new-form input[type='text'] {

View file

@ -28,7 +28,7 @@
<section class="container"> <section class="container">
<br> <br>
<div class="row"> <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"> <div class="title-row col-xs-12">
<h4 class="fa fa-plus fa-6"></h4> <h4 class="fa fa-plus fa-6"></h4>
</div> </div>

View file

@ -310,12 +310,12 @@ section.public-form field-directive .btn[disabled]{
} }
/*CREATE-NEW FORM MODAL*/ /*CREATE-NEW FORM MODAL*/
.form-item.create-new.new-form { .form-item.new-form {
background-color: #832383; background-color: #832383;
background-color: rgb(300,131,131); background-color: rgb(300,131,131);
z-index: 11; z-index: 11;
} }
.form-item.create-new.new-form:hover { .form-item.new-form:hover {
background-color: #3079b5; background-color: #3079b5;
} }
.form-item.new-form input[type='text'] { .form-item.new-form input[type='text'] {
@ -398,19 +398,23 @@ h3.forms-list-title {
font-size: 1.3em; font-size: 1.3em;
} }
.form-item.create-new .title-row{ .form-item.create-new .title-row {
padding: 0; padding: 0;
} }
.form-item.create-new .title-row h4 { .form-item.create-new .title-row h4 {
font-size: 7em; font-size: 7em;
} }
.form-item .details-row{ .form-item.create-new.new-button .details-row {
margin-top: 3.2em; padding-top: 20%;
} }
.form-item .details-row small { .form-item .details-row small {
font-size: 0.6em; font-size: 0.6em;
} }
.form-item.create-new .details-row small { .form-item.create-new .details-row small {
font-size: 0.95em; font-size: 0.95em;
} }
.form-item.create-new input {
max-width: 100%
}

View file

@ -7,29 +7,30 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
$scope = $rootScope; $scope = $rootScope;
$scope.credentials = {}; $scope.credentials = {};
$scope.error = ''; $scope.error = '';
$scope.forms = []; $scope.forms = {};
$scope.signin = function() { $scope.signin = function() {
console.log($scope.forms.signinForm); if(!$scope.forms.signinForm.$invalid){
User.login($scope.credentials).then( User.login($scope.credentials).then(
function(response) { function(response) {
Auth.login(response); Auth.login(response);
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User); $scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
if($state.previous.name !== 'home' && $state.previous.name !== 'verify' && $state.previous.name !== '') { if($state.previous.name !== 'home' && $state.previous.name !== 'verify' && $state.previous.name !== '') {
$state.go($state.previous.name); $state.go($state.previous.name);
} else { } else {
$state.go('listForms'); $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() { $scope.signup = function() {
@ -38,20 +39,22 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
return; return;
} }
User.signup($scope.credentials).then( if(!$scope.forms.signupForm.$invalid){
function(response) { User.signup($scope.credentials).then(
$state.go('signup-success'); function(response) {
}, $state.go('signup-success');
function(error) { },
console.error(error); function(error) {
if(error) { console.error(error);
$scope.error = error; if(error) {
console.error(error); $scope.error = error;
} else { console.error(error);
console.error('No response received'); } else {
} console.error('No response received');
} }
); }
);
}
}; };
} }

View file

@ -5,6 +5,7 @@ angular.module('users').controller('PasswordController', ['$scope', '$stateParam
$translate.use($window.locale); $translate.use($window.locale);
$scope.error = ''; $scope.error = '';
$scope.forms = {};
// Submit forgotten password account id // Submit forgotten password account id
$scope.askForPasswordReset = function() { $scope.askForPasswordReset = function() {
@ -24,24 +25,25 @@ angular.module('users').controller('PasswordController', ['$scope', '$stateParam
// Change user password // Change user password
$scope.resetUserPassword = function() { $scope.resetUserPassword = function() {
$scope.success = $scope.error = null; if(!$scope.forms.resetPasswordForm.$invalid){
User.resetPassword($scope.passwordDetails, $stateParams.token).then( $scope.success = $scope.error = null;
function(response){ User.resetPassword($scope.passwordDetails, $stateParams.token).then(
console.log(response.message); function(response){
// If successful show success message and clear form // If successful show success message and clear form
$scope.success = response.message; $scope.success = response.message;
$scope.error = null; $scope.error = null;
$scope.passwordDetails = null; $scope.passwordDetails = null;
// And redirect to the index page // And redirect to the index page
$state.go('reset-success'); $state.go('reset-success');
}, },
function(error){ function(error){
$scope.error = error.message || error; $scope.error = error.message || error;
$scope.success = null; $scope.success = null;
$scope.passwordDetails = null; $scope.passwordDetails = null;
} }
); );
}
}; };
} }
]); ]);

View file

@ -4,7 +4,7 @@
<img src="/static/modules/core/img/logo_white.svg" height="100px"> <img src="/static/modules/core/img/logo_white.svg" height="100px">
</div> </div>
<div class="col-xs-offset-3 col-xs-6 col-sm-offset-4 col-sm-4"> <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> <fieldset>
<div data-ng-show="error" id="signup_errors" class="text-center"> <div data-ng-show="error" id="signup_errors" class="text-center">
{{'SIGNUP_ERROR_TEXT' | translate}}: <br> {{'SIGNUP_ERROR_TEXT' | translate}}: <br>

View file

@ -1,7 +1,7 @@
<section class="row auth" data-ng-controller="PasswordController"> <section class="row auth" data-ng-controller="PasswordController">
<h3 class="col-md-12 text-center">{{ 'RESET_PASSWORD' | translate }}</h3> <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"> <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> <fieldset>
<div ng-if="error" class="text-center text-danger"> <div ng-if="error" class="text-center text-danger">
<strong>{{error}}</strong> <strong>{{error}}</strong>