Merge branch 'weixin_guange' into develop
This commit is contained in:
commit
38a58cd3fc
6
Gemfile
6
Gemfile
|
@ -50,16 +50,16 @@ gem 'elasticsearch-model'
|
|||
gem 'elasticsearch-rails'
|
||||
|
||||
#rails 3.2.22.2 bug
|
||||
# gem "test-unit", "~>3.0"
|
||||
gem "test-unit", "~>3.0"
|
||||
|
||||
### profile
|
||||
# gem 'oneapm_rpm'
|
||||
gem 'oneapm_rpm'
|
||||
|
||||
group :development do
|
||||
gem 'grape-swagger'
|
||||
gem 'better_errors', '~> 1.1.0'
|
||||
# gem "query_reviewer"
|
||||
# gem 'rack-mini-profiler', '~> 0.9.3'
|
||||
gem 'rack-mini-profiler', '~> 0.9.3'
|
||||
if RUBY_PLATFORM =~ /w32/
|
||||
gem 'win32console'
|
||||
end
|
||||
|
|
|
@ -23,7 +23,21 @@ module Mobile
|
|||
refresh_token = session[:refresh_token]
|
||||
|
||||
if access_token.present? && refresh_token.present?
|
||||
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||
begin
|
||||
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||
rescue
|
||||
info = Wechat.api.web_access_token(session[:wechat_code])
|
||||
openid =info["openid"]
|
||||
access_token =info["access_token"]
|
||||
if access_token
|
||||
session[:access_token] = access_token
|
||||
end
|
||||
refresh_token = info["refresh_token"]
|
||||
if refresh_token
|
||||
session[:refresh_token] = refresh_token
|
||||
end
|
||||
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||
end
|
||||
|
||||
access_token = refreshinfo["access_token"]
|
||||
refresh_token = refreshinfo["refresh_token"]
|
||||
|
@ -42,9 +56,16 @@ module Mobile
|
|||
user = us.register ({:login=>openid, :mail=>"#{openid}@163.com",
|
||||
:password=>"12345678", :password_confirmation=>"12345678",
|
||||
:should_confirmation_password => true})
|
||||
user.update_attributes(:lastname=>name)
|
||||
|
||||
raise user.errors.full_messages.first if user.new_record?
|
||||
user.update_attributes(:lastname=>name)
|
||||
#自动激活
|
||||
if Setting.self_registration != '3'
|
||||
user.activate
|
||||
user.last_login_on = Time.now
|
||||
if user.save
|
||||
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
||||
end
|
||||
end
|
||||
UserWechat.create!(
|
||||
openid: openid,
|
||||
user: user,
|
||||
|
|
|
@ -68,6 +68,15 @@ module Mobile
|
|||
user = us.register params.merge(:password_confirmation => params[:password],
|
||||
:should_confirmation_password => true)
|
||||
raise user.errors.full_messages.first if user.new_record?
|
||||
#自动激活
|
||||
if Setting.self_registration != '3'
|
||||
# user = automatically_register(user)
|
||||
user.activate
|
||||
user.last_login_on = Time.now
|
||||
if user.save
|
||||
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
||||
end
|
||||
end
|
||||
|
||||
if uw && !uw.real?
|
||||
user.update_attributes(:lastname=>uw.user[:lastname])
|
||||
|
|
|
@ -22,5 +22,6 @@ class UserWechat < ActiveRecord::Base
|
|||
Comment.where(author_id: old_user).update_all(author_id: u.id)
|
||||
Message.where(author_id: old_user).update_all(author_id: u.id)
|
||||
BlogComment.where(author_id: old_user).update_all(author_id: u.id)
|
||||
UserActivity.where(user_id: old_user).update_all(user_id: u.id)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue