|
|
|
@ -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,
|
|
|
|
|