微信自动激活修改
This commit is contained in:
parent
e17683d3d5
commit
22e4e56029
|
@ -5,7 +5,6 @@ module Mobile
|
||||||
class NewComment< Grape::API
|
class NewComment< Grape::API
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
include ApiHelper
|
include ApiHelper
|
||||||
include AccountHelper
|
|
||||||
resources :new_comment do
|
resources :new_comment do
|
||||||
|
|
||||||
desc "add a new comment"
|
desc "add a new comment"
|
||||||
|
@ -17,6 +16,7 @@ module Mobile
|
||||||
unless current_user
|
unless current_user
|
||||||
#如果当前用户不存在 则需要根据微信昵称注册一个帐号
|
#如果当前用户不存在 则需要根据微信昵称注册一个帐号
|
||||||
openid = session[:wechat_openid]
|
openid = session[:wechat_openid]
|
||||||
|
openid = "asfsdf"
|
||||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||||
us = UsersService.new
|
us = UsersService.new
|
||||||
|
|
||||||
|
@ -60,7 +60,13 @@ module Mobile
|
||||||
raise user.errors.full_messages.first if user.new_record?
|
raise user.errors.full_messages.first if user.new_record?
|
||||||
user.update_attributes(:lastname=>name)
|
user.update_attributes(:lastname=>name)
|
||||||
#自动激活
|
#自动激活
|
||||||
user = AccountHelper.automatically_register(user)
|
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!(
|
UserWechat.create!(
|
||||||
openid: openid,
|
openid: openid,
|
||||||
user: user,
|
user: user,
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
module Mobile
|
module Mobile
|
||||||
module Apis
|
module Apis
|
||||||
class Users < Grape::API
|
class Users < Grape::API
|
||||||
include AccountHelper
|
|
||||||
resource :users do
|
resource :users do
|
||||||
|
|
||||||
desc "查询是否已绑定"
|
desc "查询是否已绑定"
|
||||||
|
@ -70,7 +69,14 @@ module Mobile
|
||||||
:should_confirmation_password => true)
|
:should_confirmation_password => true)
|
||||||
raise user.errors.full_messages.first if user.new_record?
|
raise user.errors.full_messages.first if user.new_record?
|
||||||
#自动激活
|
#自动激活
|
||||||
user = automatically_register(user)
|
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?
|
if uw && !uw.real?
|
||||||
user.update_attributes(:lastname=>uw.user[:lastname])
|
user.update_attributes(:lastname=>uw.user[:lastname])
|
||||||
|
|
Loading…
Reference in New Issue