Skip to content
Extraits de code Groupes Projets
Valider 7c75eb59 rédigé par theworldbright's avatar theworldbright Validation de theworldbright
Parcourir les fichiers

Make access tokens belong to user not client app

parent 3fc0f64c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
class OAuthApplication < ActiveRecord::Base
belongs_to :user
validates :user_id, presence: true
validates :client_id, presence: true, uniqueness: true
validates :client_secret, presence: true
has_many :tokens
end
class Token < ActiveRecord::Base
belongs_to :o_auth_application
belongs_to :user
before_validation :setup, on: :create
......
......@@ -77,6 +77,7 @@ class User < ActiveRecord::Base
has_many :reports
has_many :o_auth_applications
has_many :tokens
before_save :guard_unconfirmed_email,
:save_person!
......
......@@ -4,6 +4,8 @@ class CreateOAuthApplications < ActiveRecord::Migration
t.belongs_to :user, index: true
t.string :client_id
t.string :client_secret
t.string :name
t.string :redirect_uris
t.timestamps null: false
end
......
class CreateTokens < ActiveRecord::Migration
def self.up
create_table :tokens do |t|
t.belongs_to :o_auth_application, index: true
t.belongs_to :user, index: true
t.string :token
t.datetime :expires_at
t.timestamps null: false
end
end
......
......@@ -240,6 +240,8 @@ ActiveRecord::Schema.define(version: 20151003142048) do
t.integer "user_id", limit: 4
t.string "client_id", limit: 255
t.string "client_secret", limit: 255
t.string "name", limit: 255
t.string "redirect_uris", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
......@@ -539,14 +541,14 @@ ActiveRecord::Schema.define(version: 20151003142048) do
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, length: {"name"=>191}, using: :btree
create_table "tokens", force: :cascade do |t|
t.integer "o_auth_application_id", limit: 4
t.string "token", limit: 255
t.integer "user_id", limit: 4
t.string "token", limit: 255
t.datetime "expires_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "tokens", ["o_auth_application_id"], name: "index_tokens_on_o_auth_application_id", using: :btree
add_index "tokens", ["user_id"], name: "index_tokens_on_user_id", using: :btree
create_table "user_preferences", force: :cascade do |t|
t.string "email_type", limit: 255
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter