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