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

Add scopes and authorization models

parent 88d02ea3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
class Authorization < ActiveRecord::Base
belongs_to :user
belongs_to :o_auth_application
has_and_belongs_to_many :scopes
# TODO: Incomplete class
end
class OAuthApplication < ActiveRecord::Base
belongs_to :user
has_many :authorizations
validates :client_id, presence: true, uniqueness: true
validates :client_secret, presence: true
......
class Scope < ActiveRecord::Base
has_and_belongs_to_many :tokens
has_and_belongs_to_many :authorizations
validates :name, presence: true, uniqueness: true
# TODO: Incomplete class
end
class Token < ActiveRecord::Base
belongs_to :user
has_and_belongs_to_many :scopes
before_validation :setup, on: :create
......
......@@ -77,6 +77,7 @@ class User < ActiveRecord::Base
has_many :reports
has_many :o_auth_applications
has_many :authorizations
has_many :tokens
before_save :guard_unconfirmed_email,
......
class CreateAuthorizations < ActiveRecord::Migration
def change
create_table :authorizations do |t|
t.belongs_to :user, index: true
t.belongs_to :o_auth_application, index: true
t.timestamps null: false
end
end
end
class CreateScope < ActiveRecord::Migration
def change
create_table :scopes do |t|
t.string :name
t.timestamps null: false
end
end
end
class CreateAuthorizationsScopesJoinTable < ActiveRecord::Migration
def change
create_table :authorizations_scopes, id: false do |t|
t.belongs_to :authorization, index: true
t.belongs_to :scope, index: true
end
end
end
class CreateScopesTokensJoinTable < ActiveRecord::Migration
def change
create_table :scopes_tokens, id: false do |t|
t.belongs_to :scope, index: true
t.belongs_to :token, index: true
end
end
end
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