From 64eacc2d5e84e9d77f60c7bcadd8f41fd2495749 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 12 Aug 2016 10:10:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E9=BB=98=E8=AE=A4=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 12 +++++++++--- app/api/mobile/apis/users.rb | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 0713a48a3..2c5ab7754 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -20,14 +20,20 @@ module Mobile #如果当前用户不存在 openid = session[:wechat_openid] raise "无法获取到openid,请在微信中打开本页面" unless openid - us = UsersService.new #login mail password + openid_length = openid.length + + login = openid[0..10]+openid[openid_length-3..openid_length-1] - login = openid[0..3]+"***"+openid.last + name = openid[0..3]+"***"+openid.last user = us.register ({:login=>login, :mail=>login+"@163.com", - :password=>"12345678", :password_confirmation=>"12345678", :should_confirmation_password => true}) + :password=>"12345678", :password_confirmation=>"12345678", + :should_confirmation_password => true}) + + user.update_attributes(:lastname=>name) + raise user.errors.full_messages.first if user.new_record? UserWechat.create!( openid: openid, diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 30e4cc1f9..19cce07e7 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -67,6 +67,7 @@ module Mobile user[:password] = params[:password] user[:password_confirmation] = params[:password] user[:should_confirmation_password] = true + user[:lastname]="" user.save! else us = UsersService.new