Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
cxt 6 years ago
commit 004c15be3e

@ -55,6 +55,10 @@ class AccountsController < ApplicationController
container_type: pre == 'p' ? 'Phone' : 'Mail', container_type: pre == 'p' ? 'Phone' : 'Mail',
score: 500 score: 500
) )
# 注册时,记录是否是引流用户
ip = request.remote_ip
ua = UserAgent.find_by_ip(ip)
ua.update_column(:agent_type, UserAgent::USER_REGISTER) if ua
successful_authentication(@user) successful_authentication(@user)
session[:user_id] = @user.id session[:user_id] = @user.id
normal_status("注册成功") normal_status("注册成功")
@ -110,7 +114,7 @@ class AccountsController < ApplicationController
# generate a key and set cookie if autologin # generate a key and set cookie if autologin
set_autologin_cookie(user) set_autologin_cookie(user)
UserAction.create(:action_id => user.try(:id), :action_type => "Login", :user_id => user.try(:id)) UserAction.create(:action_id => user.try(:id), :action_type => "Login", :user_id => user.try(:id), :ip => request.remote_ip)
# 注册完成后有一天的试用申请 # 注册完成后有一天的试用申请
UserDayCertification.create(user_id: user.id, status: 1) UserDayCertification.create(user_id: user.id, status: 1)
@ -133,7 +137,7 @@ class AccountsController < ApplicationController
end end
def logout def logout
UserAction.create(action_id: User.current.id, action_type: "Logout", user_id: User.current.id) UserAction.create(action_id: User.current.id, action_type: "Logout", user_id: User.current.id, :ip => request.remote_ip)
session[:user_id] = nil session[:user_id] = nil
logout_user logout_user
render :json => {status: 1, message: "退出成功!"} render :json => {status: 1, message: "退出成功!"}

@ -0,0 +1,6 @@
class UserAgent < ApplicationRecord
has_many :user_actionss, :foreign_key => "ip", :primary_key => "ip"
USER_AD = 1 # 广告宣传的引流
USER_REGISTER = 2 # 引流注册
USER_COMPETITION = 3 # 引流参加竞赛
end

@ -20,7 +20,7 @@ module ElasticsearchAble
def highlight_options def highlight_options
{ {
fragment_size: EduSetting.get('es_highlight_fragment_size') || 30, fragment_size: EduSetting.get('es_highlight_fragment_size') || 30,
tag: '<span>' tag: '<span class="highlight">'
} }
end end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe UserAgent, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save