From af98434c29de8939e809dcd7445a7bf79c4d58a1 Mon Sep 17 00:00:00 2001 From: Yang Zhao Date: Wed, 28 Dec 2016 05:34:43 +0000 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=AE=E6=94=B9=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 3 +- app/models/user.rb | 2 +- app/views/sessions/show.json.jbuilder | 2 +- public/pages/alter_info.html | 97 +++++++++++++++++++++++++-- 4 files changed, 94 insertions(+), 10 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a78428f..c0ccdf4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,7 @@ class UsersController < ApplicationController before_action :authenticate, except: [ :emailExist, :usernameExist, :create ] + skip_before_action :verify_authenticity_token, :only => [:emailExist,:usernameExist,:create,:update] def emailExist if checkExist?(:email, params[:email]) @@ -42,6 +43,6 @@ class UsersController < ApplicationController end def user_params - params.require(:user).permit(:name, :password, :password_confirmation, :email, :phone) + params.require(:user).permit(:name,:password, :password_confirmation, :email, :phone) end end diff --git a/app/models/user.rb b/app/models/user.rb index da707d3..7dbe1c5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,7 +9,7 @@ class User < ActiveRecord::Base validates :name, presence: true, uniqueness: true, length: { maximum: 30 } validates :email, presence: true, uniqueness: true, length: { maximum: 50}, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i } - validates :password, length: { minimum: 6 } + validates :password, length: { minimum: 6 },on:create validates :phone, presence: true, uniqueness: true, format: { with: /\A[0-9]{11,11}\Z/i }, multiline: false end diff --git a/app/views/sessions/show.json.jbuilder b/app/views/sessions/show.json.jbuilder index daacbcb..fa512e4 100644 --- a/app/views/sessions/show.json.jbuilder +++ b/app/views/sessions/show.json.jbuilder @@ -1 +1 @@ -json.extract! current_user, :id, :name, :email, :created_at \ No newline at end of file +json.extract! current_user, :id, :name, :email, :created_at,:phone \ No newline at end of file diff --git a/public/pages/alter_info.html b/public/pages/alter_info.html index bef4e75..68d6572 100644 --- a/public/pages/alter_info.html +++ b/public/pages/alter_info.html @@ -62,21 +62,21 @@
- +
- +
- +
@@ -84,7 +84,7 @@ @@ -104,14 +104,14 @@
- +
- +
@@ -119,7 +119,7 @@ @@ -144,6 +144,89 @@ + \ No newline at end of file