From 97906d17f7f305032851c6baef9064642486ab5c Mon Sep 17 00:00:00 2001 From: AnshitaVishwa Date: Sun, 3 Nov 2019 14:07:45 +0530 Subject: [PATCH 1/2] Name Field in Users Plugin take correct input format --- config/database.yml | 2 +- plugins/010-users/app/controllers/users_controller.rb | 6 +++--- plugins/010-users/app/views/users/_form.html.slim | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/database.yml b/config/database.yml index 41377ac4..1d7041d1 100644 --- a/config/database.yml +++ b/config/database.yml @@ -11,7 +11,7 @@ development: pool: 5 database: hda_development username: root - password: hda + password: very_strong_password host: localhost socket: <%= [ '/var/lib/mysql/mysql.sock', # Fedora. diff --git a/plugins/010-users/app/controllers/users_controller.rb b/plugins/010-users/app/controllers/users_controller.rb index 582e9905..260b90d5 100644 --- a/plugins/010-users/app/controllers/users_controller.rb +++ b/plugins/010-users/app/controllers/users_controller.rb @@ -29,7 +29,7 @@ def index def create sleep 2 if development? @user = User.new(params_user_create) - @user.save + @user.save @users = User.all_users unless @user.errors.any? end @@ -38,7 +38,7 @@ def update user = User.find params[:id] name = user.name if can_i_edit_details?(user) - if(params[:name].strip.length !=0) + if(params[:name].strip.length !=0 && (/[^a-zA-Z]+/ =~ params[:name]) == nil) user.name = params[:name] user.save! name = user.name @@ -107,7 +107,7 @@ def update_password def update_name @user = User.find(params[:id]) - @user.update_attributes(params_name_update) + @user.update_attributes(params_name_update) render :json => { :status => @user.errors.any? ? :not_acceptable : :ok } end diff --git a/plugins/010-users/app/views/users/_form.html.slim b/plugins/010-users/app/views/users/_form.html.slim index 6936ccbf..5a33c64d 100644 --- a/plugins/010-users/app/views/users/_form.html.slim +++ b/plugins/010-users/app/views/users/_form.html.slim @@ -19,7 +19,7 @@ .controls= f.text_field :login, :size => 16, :maxlength => 20, :class=>'form-control',:placeholder => t('username') .control-group.form-group - .controls= f.text_field :name, :size => 16, :maxlength => 64, :class=>'form-control', :placeholder => t('full_name') + .controls= f.text_field :name, :size => 16, :maxlength => 64, :class=>'form-control',:pattern => "[a-zA-Z]+", :placeholder => t('full_name') .control-group.form-group .controls= f.password_field :password, :size => 16, :maxlength => 24, :class=>'form-control',:placeholder => t('password') From 2235caa618ce4cda33f7ea904b03046234433b49 Mon Sep 17 00:00:00 2001 From: AnshitaVishwa Date: Sun, 3 Nov 2019 14:51:05 +0530 Subject: [PATCH 2/2] Name Field in Users Plugin take correct input format --- config/database.yml | 2 +- plugins/010-users/app/controllers/users_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/database.yml b/config/database.yml index 1d7041d1..41377ac4 100644 --- a/config/database.yml +++ b/config/database.yml @@ -11,7 +11,7 @@ development: pool: 5 database: hda_development username: root - password: very_strong_password + password: hda host: localhost socket: <%= [ '/var/lib/mysql/mysql.sock', # Fedora. diff --git a/plugins/010-users/app/controllers/users_controller.rb b/plugins/010-users/app/controllers/users_controller.rb index 260b90d5..6bf70066 100644 --- a/plugins/010-users/app/controllers/users_controller.rb +++ b/plugins/010-users/app/controllers/users_controller.rb @@ -29,7 +29,7 @@ def index def create sleep 2 if development? @user = User.new(params_user_create) - @user.save + @user.save @users = User.all_users unless @user.errors.any? end @@ -107,7 +107,7 @@ def update_password def update_name @user = User.find(params[:id]) - @user.update_attributes(params_name_update) + @user.update_attributes(params_name_update) render :json => { :status => @user.errors.any? ? :not_acceptable : :ok } end