diff --git a/app/controllers/sso_controller.rb b/app/controllers/sso_controller.rb index 0ae7b7449..2a7ac6db3 100644 --- a/app/controllers/sso_controller.rb +++ b/app/controllers/sso_controller.rb @@ -30,8 +30,8 @@ class SsoController < ApplicationController end def login(id) - - start_user_session(user) + sso = Sso.find(id) + start_user_session(sso.user) end end diff --git a/app/models/sso.rb b/app/models/sso.rb new file mode 100644 index 000000000..d7cf54dc3 --- /dev/null +++ b/app/models/sso.rb @@ -0,0 +1,4 @@ +class Sso < ActiveRecord::Base + belongs_to :user + attr_accessible :email, :name, :openid, :password, :school, :sex +end diff --git a/app/models/user.rb b/app/models/user.rb index dc7a3e741..9b8cb2b8d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -181,6 +181,8 @@ class User < Principal has_one :user_wechat + has_one :sso + # add by zjc has_one :level, :class_name => 'UserLevels', :dependent => :destroy has_many :memos , :foreign_key => 'author_id' diff --git a/db/migrate/20160504060751_create_ssos.rb b/db/migrate/20160504060751_create_ssos.rb new file mode 100644 index 000000000..a01a7fe35 --- /dev/null +++ b/db/migrate/20160504060751_create_ssos.rb @@ -0,0 +1,16 @@ +class CreateSsos < ActiveRecord::Migration + def change + create_table :ssos do |t| + t.references :user + t.string :openid + t.string :name + t.string :password + t.string :email + t.integer :sex + t.string :school + + t.timestamps + end + add_index :ssos, :user_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 3d3a54105..677b030df 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160429030819) do +ActiveRecord::Schema.define(:version => 20160504060751) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1673,15 +1673,6 @@ ActiveRecord::Schema.define(:version => 20160429030819) do t.datetime "updated_at", :null => false end - create_table "shield_wechats", :force => true do |t| - t.string "container_type" - t.integer "container_id" - t.string "shield_type" - t.integer "shield_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1700,6 +1691,20 @@ ActiveRecord::Schema.define(:version => 20160429030819) do t.integer "project_id" end + create_table "ssos", :force => true do |t| + t.integer "user_id" + t.string "openid" + t.string "name" + t.string "password" + t.string "email" + t.integer "sex" + t.string "school" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "ssos", ["user_id"], :name => "index_ssos_on_user_id" + create_table "student_work_projects", :force => true do |t| t.integer "homework_common_id" t.integer "student_work_id"