dev_jupyter
commit
0b0241727e
@ -0,0 +1,13 @@
|
||||
class Oauth::CasController < Oauth::BaseController
|
||||
def create
|
||||
user, is_new_user = Oauth::CreateORFindCasUserService.call(current_user, auth_hash)
|
||||
successful_authentication(user)
|
||||
|
||||
redirect_to root_url
|
||||
end
|
||||
|
||||
|
||||
def auth_hash
|
||||
JSON.parse(CGI.unescape(request.env['omniauth.auth'].extra.to_json))
|
||||
end
|
||||
end
|
@ -1,11 +1,32 @@
|
||||
class Oauth::WechatController < Oauth::BaseController
|
||||
def create
|
||||
user, new_user = Oauth::CreateOrFindWechatAccountService.call(current_user ,params)
|
||||
# user, new_user = Oauth::CreateOrFindWechatAccountService.call(current_user ,params)
|
||||
|
||||
successful_authentication(user)
|
||||
begin
|
||||
code = params['code'].to_s.strip
|
||||
tip_exception("code不能为空") if code.blank?
|
||||
new_user = false
|
||||
|
||||
render_ok(new_user: new_user)
|
||||
rescue Oauth::CreateOrFindWechatAccountService::Error => ex
|
||||
render_error(ex.message)
|
||||
result = WechatOauth::Service.access_token(code)
|
||||
result = WechatOauth::Service.user_info(result['access_token'], result['openid'])
|
||||
|
||||
# 存在该用户
|
||||
open_user = OpenUsers::Wechat.find_by(uid: result['unionid'])
|
||||
if open_user.present? && open_user.user.present?
|
||||
successful_authentication(open_user.user)
|
||||
else
|
||||
if current_user.blank? || !current_user.logged?
|
||||
new_user = true
|
||||
set_session_openid(result['openid'])
|
||||
set_session_unionid(result['unionid'])
|
||||
else
|
||||
OpenUsers::Wechat.create!(user: current_user, uid: result['unionid'])
|
||||
end
|
||||
end
|
||||
|
||||
render_ok(new_user: new_user)
|
||||
rescue WechatOauth::Error => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
end
|
||||
end
|
@ -1,3 +1,4 @@
|
||||
class HackCode < ApplicationRecord
|
||||
# 编程题代码相关
|
||||
belongs_to :hack
|
||||
end
|
||||
|
@ -0,0 +1,9 @@
|
||||
class OpenUsers::Cas < OpenUser
|
||||
def nickname
|
||||
extra&.[]('nickname')
|
||||
end
|
||||
|
||||
def en_type
|
||||
'cas'
|
||||
end
|
||||
end
|
@ -0,0 +1,31 @@
|
||||
class Oauth::CreateORFindCasUserService < ApplicationService
|
||||
|
||||
def initialize(user, params)
|
||||
@user = user
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
return [@user, false] if @user
|
||||
|
||||
open_user = OpenUsers::Cas.find_or_initialize_by(uid: @params['user']) do |u|
|
||||
u.extra = @params
|
||||
end
|
||||
|
||||
return [open_user.user, false] if open_user.persisted?
|
||||
|
||||
@user = User.new(login: User.generate_login('C'), type: 'User', status: User::STATUS_ACTIVE, nickname: @params['comsys_name'], lastname: @params['comsys_name'])
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
@user.save!
|
||||
@user.create_user_extension!
|
||||
|
||||
open_user.user = @user
|
||||
open_user.save!
|
||||
|
||||
Rails.cache.write(open_user.can_bind_cache_key, 1, expires_in: 1.hours)
|
||||
end
|
||||
|
||||
[@user, true]
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
<% if @message.present? %>
|
||||
$.notify({ message: "<%= @message %>" });
|
||||
<% else %>
|
||||
$(".discipline-list-container").html("<%= j(render :partial => 'admins/disciplines/shared/list') %>");
|
||||
<% end %>
|
@ -0,0 +1 @@
|
||||
$(".salesman-channel-list-container").html("<%= j(render partial: 'admins/salesman_channels/shared/list') %>")
|
@ -0,0 +1 @@
|
||||
$(".salesman-customer-list-container").html("<%= j(render partial: 'admins/salesman_customers/shared/list') %>")
|
@ -0,0 +1,5 @@
|
||||
<% if @message.present? %>
|
||||
$.notify({ message: "<%= @message %>" });
|
||||
<% else %>
|
||||
$(".sub-discipline-list-container").html("<%= j(render :partial => 'admins/sub_disciplines/shared/list') %>");
|
||||
<% end %>
|
@ -0,0 +1,5 @@
|
||||
<% if @message.present? %>
|
||||
$.notify({ message: "<%= @message %>" });
|
||||
<% else %>
|
||||
$(".tag-discipline-list-container").html("<%= j(render :partial => 'admins/tag_disciplines/shared/list') %>");
|
||||
<% end %>
|
@ -0,0 +1,12 @@
|
||||
json.activities @activities do |activity|
|
||||
json.(activity, :course_act_id, :course_act_type)
|
||||
json.author do
|
||||
user = activity.user
|
||||
json.name user.real_name
|
||||
json.login user.login
|
||||
json.img url_to_avatar(user)
|
||||
end
|
||||
json.created_at activity.created_at.strftime('%m-%d %H:%M:')
|
||||
json.container_name activity.container_name
|
||||
json.container_type activity.course_act_type == "HomeworkCommon" ? activity.course_act&.homework_type : ""
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddShowMoblieToSubjects < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :subjects, :show_mobile, :boolean, :default => false
|
||||
end
|
||||
end
|
@ -0,0 +1,8 @@
|
||||
class SyncSubjectdsMobile < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
|
||||
SubDisciplineContainer.find_each do |sc|
|
||||
Subject.find(sc.container_id).update_column(:show_mobile, true)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class AddPositionToDiscipline < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :disciplines, :position, :integer, default: 0
|
||||
add_column :sub_disciplines, :position, :integer, default: 0
|
||||
add_column :tag_disciplines, :position, :integer, default: 0
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
class MigrateDisciplinePosition < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
Discipline.all.each_with_index do |discipline, i|
|
||||
discipline.update_column("position", i + 1)
|
||||
|
||||
discipline.sub_disciplines.each_with_index do |sub, j|
|
||||
sub.update_column("position", j + 1)
|
||||
|
||||
sub.tag_disciplines.each_with_index do |tag, k|
|
||||
tag.update_column("position", k + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
class AddUniqIndexToSalesmanChannel < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
sql = %Q(delete from salesman_channels where (salesman_id, school_id) in
|
||||
(select * from (select salesman_id, school_id from salesman_channels group by salesman_id, school_id having count(*) > 1) a)
|
||||
and id not in (select * from (select min(id) from salesman_channels group by salesman_id, school_id having count(*) > 1 order by id) b))
|
||||
ActiveRecord::Base.connection.execute sql
|
||||
|
||||
add_index :salesman_channels, [:salesman_id, :school_id], unique: true
|
||||
end
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
class AddUniqIndexToSalesmanCustomer < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
sql = %Q(delete from salesman_customers where (salesman_id, user_id) in
|
||||
(select * from (select salesman_id, user_id from salesman_customers group by salesman_id, user_id having count(*) > 1) a)
|
||||
and id not in (select * from (select min(id) from salesman_customers group by salesman_id, user_id having count(*) > 1 order by id) b))
|
||||
ActiveRecord::Base.connection.execute sql
|
||||
|
||||
add_index :salesman_customers, [:salesman_id, :user_id], unique: true
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class MigrateCourseMessageAct < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
CourseActivity.where(course_act_type: "JoinCourse").update_all(course_act_type: "CourseMessage")
|
||||
end
|
||||
end
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue