diff --git a/Gemfile b/Gemfile
index 51f6d66..579a4e7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -45,6 +45,7 @@
gem 'devise_invitable'
gem 'omniauth'
gem 'omniauth-shibboleth'
+gem 'omniauth-orcid'
#rolify for roles
gem 'rolify'
# Gems for repository integration
diff --git a/Gemfile.lock b/Gemfile.lock
index 45586fc..3dc0008 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -160,6 +160,7 @@
jquery-ui-rails (5.0.5)
railties (>= 3.2.16)
json (1.8.3)
+ jwt (1.5.6)
kaminari (0.17.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
@@ -202,14 +203,26 @@
minitest (>= 5.0)
ruby-progressbar
multi_json (1.12.1)
+ multi_xml (0.5.5)
multipart-post (2.0.0)
mysql2 (0.3.21)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
+ oauth2 (1.2.0)
+ faraday (>= 0.8, < 0.10)
+ jwt (~> 1.0)
+ multi_json (~> 1.3)
+ multi_xml (~> 0.5)
+ rack (>= 1.2, < 3)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
rack (>= 1.0, < 3)
+ omniauth-oauth2 (1.4.0)
+ oauth2 (~> 1.0)
+ omniauth (~> 1.2)
+ omniauth-orcid (1.2.1)
+ omniauth-oauth2 (~> 1.3)
omniauth-shibboleth (1.2.1)
omniauth (>= 1.0.0)
orm_adapter (0.5.0)
@@ -343,6 +356,7 @@
minitest-reporters
mysql2 (~> 0.3.18)
omniauth
+ omniauth-orcid
omniauth-shibboleth
protected_attributes
pundit
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index aa0b716..1ac40b3 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,9 +1,24 @@
class SessionsController < Devise::SessionsController
+ def oauth_create
+ existing_user = User.find_by_email(params[:user][:email])
+
+ unless params[:omniauth].nil?
+
+puts "OMNIAUTH: #{params[:omniauth].inspect}"
+puts "REQUEST: #{request.env['omniauth.auth'].inspect}"
+
+ existing_user = UserIdentifier.find_by(identifier: params[:omniauth][:auth])
+
+ end
+
+ end
+
# Capture the user's shibboleth id if they're coming in from an IDP
+ # ------------------------------------------------------------
def create
existing_user = User.find_by_email(params[:user][:email])
-
+
if !existing_user.nil? && !params[:shibboleth_data].nil? then
#after authentication verify if session[:shibboleth] exists
existing_user.update_attributes(shibboleth_id: session[:shibboleth_data][:uid])
diff --git a/app/controllers/users/omniauth_callback_controller.rb b/app/controllers/users/omniauth_callback_controller.rb
deleted file mode 100644
index ee19c5c..0000000
--- a/app/controllers/users/omniauth_callback_controller.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
-
- def shibboleth
- if user_signed_in? && current_user.shibboleth_id.present? && current_user.shibboleth_id.length > 0 then
- flash[:warning] = I18n.t('devise.failure.already_authenticated')
- redirect_to root_path
- else
- auth = request.env['omniauth.auth'] || {}
- eppn = auth['extra']['raw_info']['eppn']
- uid = nil
- if !eppn.blank? then
- uid = eppn
- elsif !auth['uid'].blank? then
- uid = auth['uid']
- elsif !auth['extra']['raw_info']['targeted-id'].blank? then
- uid = auth['extra']['raw_info']['targeted-id']
- end
-
- if !uid.nil? && !uid.blank? then
- s_user = User.where(shibboleth_id: uid).first
- # Take out previous record if was not confirmed.
- if !s_user.nil? && s_user.confirmed_at.nil? then
- sign_out s_user
- User.delete(s_user.id)
- s_user = nil
- end
-
- # Stops Shibboleth ID being blocked if email incorrectly entered.
- if !s_user.nil? && s_user.try(:persisted?) then
- flash[:notice] = I18n.t('devise.omniauth_callbacks.success', :kind => 'Shibboleth')
- sign_in s_user
- redirect_to root_path
- else
- if user_signed_in? then
- current_user.update_attribute('shibboleth_id', uid)
- user_id = current_user.id
- sign_out current_user
- session.delete(:shibboleth_data)
- s_user = User.find(user_id)
- sign_in s_user
- redirect_to edit_user_registration_path
- else
- session[:shibboleth_data] = request.env['omniauth.auth']
- session[:shibboleth_data][:uid] = uid
- redirect_to new_user_registration_url(:nosplash => 'true')
- end
- end
- else
- redirect_to root_path
- end
- end
- end
-end
diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb
new file mode 100644
index 0000000..d562337
--- /dev/null
+++ b/app/controllers/users/omniauth_callbacks_controller.rb
@@ -0,0 +1,73 @@
+class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
+
+ # -------------------------------------------------------------
+ def orcid
+ @user = User.from_omniauth(request.env["omniauth.auth"])
+
+ if @user.persisted?
+ sign_in_and_redirect @user, event: :authentication
+ set_flash_message(:notice, :success, kind: 'Orcid') if is_navigational_format?
+
+ else
+ session["devise.orcid_data"] = request.env["omniauth.auth"]
+ redirect_to new_user_registration_url
+ end
+ end
+
+ # -------------------------------------------------------------
+ def shibboleth
+ if user_signed_in? && current_user.shibboleth_id.present? && current_user.shibboleth_id.length > 0 then
+ flash[:warning] = I18n.t('devise.failure.already_authenticated')
+ redirect_to root_path
+ else
+ auth = request.env['omniauth.auth'] || {}
+ eppn = auth['extra']['raw_info']['eppn']
+ uid = nil
+ if !eppn.blank? then
+ uid = eppn
+ elsif !auth['uid'].blank? then
+ uid = auth['uid']
+ elsif !auth['extra']['raw_info']['targeted-id'].blank? then
+ uid = auth['extra']['raw_info']['targeted-id']
+ end
+
+ if !uid.nil? && !uid.blank? then
+ s_user = User.where(shibboleth_id: uid).first
+ # Take out previous record if was not confirmed.
+ if !s_user.nil? && s_user.confirmed_at.nil? then
+ sign_out s_user
+ User.delete(s_user.id)
+ s_user = nil
+ end
+
+ # Stops Shibboleth ID being blocked if email incorrectly entered.
+ if !s_user.nil? && s_user.try(:persisted?) then
+ flash[:notice] = I18n.t('devise.omniauth_callbacks.success', :kind => 'Shibboleth')
+ sign_in s_user
+ redirect_to root_path
+ else
+ if user_signed_in? then
+ current_user.update_attribute('shibboleth_id', uid)
+ user_id = current_user.id
+ sign_out current_user
+ session.delete(:shibboleth_data)
+ s_user = User.find(user_id)
+ sign_in s_user
+ redirect_to edit_user_registration_path
+ else
+ session[:shibboleth_data] = request.env['omniauth.auth']
+ session[:shibboleth_data][:uid] = uid
+ redirect_to new_user_registration_url(:nosplash => 'true')
+ end
+ end
+ else
+ redirect_to root_path
+ end
+ end
+ end
+
+ # -------------------------------------------------------------
+ def failure
+ redirect_to root_path
+ end
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index ab016a7..7df8be4 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,61 +1,65 @@
class User < ActiveRecord::Base
include GlobalHelpers
+ # Collect all the available Omniauth Schemes
+ omniauth_schemes = IdentifierScheme.all.collect{ |scheme| scheme.name.downcase.to_sym }
+
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
- devise :invitable, :database_authenticatable, :registerable, :recoverable, :rememberable,
- :trackable, :validatable, :confirmable, :omniauthable, :omniauth_providers => [:shibboleth]
+ devise :invitable, :database_authenticatable, :registerable, :recoverable,
+ :rememberable, :trackable, :validatable, :confirmable,
+ :omniauthable, :omniauth_providers => omniauth_schemes
- #associations between tables
- belongs_to :user_type
- belongs_to :user_status
- has_many :answers
- has_many :user_org_roles
- has_many :project_groups, :dependent => :destroy
- #has_many :organisations , through: :user_org_roles
- has_many :user_role_types, through: :user_org_roles
- has_many :user_identifiers
- has_one :language
+ #associations between tables
+ belongs_to :user_type
+ belongs_to :user_status
+ has_many :answers
+ has_many :user_org_roles
+ has_many :project_groups, :dependent => :destroy
+ #has_many :organisations , through: :user_org_roles
+ has_many :user_role_types, through: :user_org_roles
+ has_many :user_identifiers
+ has_one :language
- belongs_to :organisation
+ belongs_to :organisation
- has_many :projects, through: :project_groups do
- def filter(query)
- return self unless query.present?
+ has_many :projects, through: :project_groups do
+ def filter(query)
+ return self unless query.present?
- t = self.arel_table
- q = "%#{query}%"
+ t = self.arel_table
+ q = "%#{query}%"
- conditions = t[:title].matches(q)
+ conditions = t[:title].matches(q)
- columns = %i(
- grant_number identifier description principal_investigator data_contact
- )
- columns = ['grant_number', 'identifier', 'description', 'principal_investigator', 'data_contact']
+ columns = %i(
+ grant_number identifier description principal_investigator data_contact
+ )
+ columns = ['grant_number', 'identifier', 'description', 'principal_investigator', 'data_contact']
- columns.each {|col| conditions = conditions.or(t[col].matches(q)) }
+ columns.each {|col| conditions = conditions.or(t[col].matches(q)) }
- self.where(conditions)
- end
+ self.where(conditions)
end
+ end
- has_and_belongs_to_many :roles, :join_table => :users_roles
+ has_and_belongs_to_many :roles, :join_table => :users_roles
- has_many :plan_sections
+ has_many :plan_sections
- accepts_nested_attributes_for :roles
- attr_accessible :password_confirmation, :encrypted_password, :remember_me, :id, :email,
- :firstname, :last_login,:login_count, :orcid_id, :password, :shibboleth_id,
- :user_status_id, :surname, :user_type_id, :organisation_id, :skip_invitation,
- :other_organisation, :accept_terms, :role_ids, :dmponline3, :api_token,
- :language_id, :organisation
+ accepts_nested_attributes_for :roles
+ attr_accessible :password_confirmation, :encrypted_password, :remember_me, :id, :email,
+ :firstname, :last_login,:login_count, :orcid_id, :password, :shibboleth_id,
+ :user_status_id, :surname, :user_type_id, :organisation_id, :skip_invitation,
+ :other_organisation, :accept_terms, :role_ids, :dmponline3, :api_token,
+ :language_id, :organisation
- # FIXME: The duplication in the block is to set defaults. It might be better if
- # they could be set in Settings::PlanList itself, if possible.
- has_settings :plan_list, class_name: 'Settings::PlanList' do |s|
- s.key :plan_list, defaults: { columns: Settings::PlanList::DEFAULT_COLUMNS }
- end
+ # FIXME: The duplication in the block is to set defaults. It might be better if
+ # they could be set in Settings::PlanList itself, if possible.
+ has_settings :plan_list, class_name: 'Settings::PlanList' do |s|
+ s.key :plan_list, defaults: { columns: Settings::PlanList::DEFAULT_COLUMNS }
+ end
##
# gives either the name of the user, or the email if name unspecified
@@ -335,4 +339,23 @@
end
end
+ ##
+ # Load the user based on the scheme and id provided by the Omniauth call
+ # --------------------------------------------------------------
+ def self.from_omniauth(auth)
+puts "USER.FROM_OMNIAUTH: #{auth.inspect}"
+
+ scheme = IdentifierScheme.find_by(name: auth.provider.downcase)
+
+ if scheme.nil?
+ throw Exception.new('Unknown OAuth provider: ' + auth.provider)
+ else
+ joins(:user_identifiers).where(identifier: auth.uid,
+ identifier_scheme: scheme).first_or_create do |user|
+ user.email = auth.info.email
+ user.password = Devise.friendly_token[0, 20]
+ end
+ end
+ end
+
end
diff --git a/app/views/devise/registrations/_external_identifier.html.erb b/app/views/devise/registrations/_external_identifier.html.erb
index cac7b72..3faef43 100644
--- a/app/views/devise/registrations/_external_identifier.html.erb
+++ b/app/views/devise/registrations/_external_identifier.html.erb
@@ -1,25 +1,19 @@
-
)">
-
- <% if id.nil? || id == '' %>
-
- <%= link_to "#{constant("identifier_schemes.#{scheme.name}.connect")}",
- "#{scheme.auth_uri}",
- title: constant("identifier_schemes.#{scheme.name}.tooltip") %>
-
- <% else %>
- <% uri = "#{scheme.user_uri.gsub(/\{id\}/, id)}" %>
- <%= link_to uri, uri, target: '_blank',
- title: constant("identifier_schemes.#{scheme.name}.tooltip") %>
- <% end %>
-
+<% api_key = scheme.api_key ||= '' %>
-
\ No newline at end of file
+
+
+ <% if id.nil? || id == '' %>
+
+ <%= link_to "#{t("identifier_schemes.#{scheme.name}.connect")}",
+ Rails.application.routes.url_helpers.send(
+ "user_#{scheme.name.downcase}_omniauth_authorize_path"
+ ),
+ title: t("identifier_schemes.#{scheme.name}.tooltip") %>
+
+ <% else %>
+ <% uri = "#{scheme.landing_page_uri.gsub(/\{id\}/, id)}" %>
+ <%= link_to uri, uri, target: '_blank',
+ title: t("identifier_schemes.#{scheme.name}.tooltip") %>
+ <% end %>
+
diff --git a/config/initializers/devise_example.rb b/config/initializers/devise_example.rb
index af16333..e55980f 100644
--- a/config/initializers/devise_example.rb
+++ b/config/initializers/devise_example.rb
@@ -248,6 +248,18 @@
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
+ # Dynamically register the Omniauth Providers
+ ActiveSupport.on_load(:active_record) do
+ IdentifierScheme.all.each do |scheme|
+
+ puts "Registering Omniauth provider: #{scheme.name}"
+ config.omniauth "#{scheme.name.downcase}".to_sym,
+ "#{scheme.api_key}",
+ "#{scheme.api_secret}",
+ scope: JSON.parse(scheme.params)
+ end
+ end
+
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
# change the failure app, you can configure them inside the config.warden block.
@@ -269,7 +281,7 @@
#
# When using omniauth, Devise cannot automatically set Omniauth path,
# so you need to do it manually. For the users scope, it would be:
- #config.omniauth_path_prefix = "/my_engine/users/auth"
+ config.omniauth_path_prefix = "/users/auth"
config.warden do |manager|
manager.failure_app = CustomFailure
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 05939aa..c97bd2a 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -859,6 +859,11 @@
no_auth_for_endpoint: '{"Error":"You do not have authorisation to view this endpoint"}'
bad_resource: '{"Error":"You do not have authorisation to view this resource"}'
+ identifier_schemes:
+ ORCID:
+ connect: 'Schließen sie ihr konto ORCID'
+ tooltip: 'ORCID bietet eine persistente digitale Kennung, die Sie von anderen Forschern unterscheidet.'
+
magic_strings:
organisation_types:
funder: 'Funder'
@@ -885,8 +890,4 @@
plans: 'plans'
templates: 'templates'
statistics: 'statistics'
- identifier_schemes:
- ORCID:
- connect_icon: '/assets/orcid.png'
- tooltip: 'ORCID bietet eine persistente digitale Kennung, die Sie von anderen Forschern unterscheidet.'
languages:
diff --git a/config/locales/en-UK.yml b/config/locales/en-UK.yml
index 7acf644..1090b81 100644
--- a/config/locales/en-UK.yml
+++ b/config/locales/en-UK.yml
@@ -954,6 +954,11 @@
no_auth_for_endpoint: '{"Error":"You do not have authorisation to view this endpoint"}'
bad_resource: '{"Error":"You do not have authorisation to view this resource"}'
+ identifier_schemes:
+ ORCID:
+ connect: 'Connect your ORCID'
+ tooltip: 'ORCID provides a persistent digital identifier that distinguishes you from other researchers.'
+
magic_strings:
organisation_types:
funder: 'Funder'
@@ -980,8 +985,4 @@
plans: 'plans'
templates: 'templates'
statistics: 'statistics'
- identifier_schemes:
- ORCID:
- connect_icon: '/assets/orcid.png'
- tooltip: 'ORCID provides a persistent digital identifier that distinguishes you from other researchers.'
languages:
diff --git a/config/locales/en-US.yml b/config/locales/en-US.yml
index 8254981..a3b6328 100644
--- a/config/locales/en-US.yml
+++ b/config/locales/en-US.yml
@@ -944,6 +944,11 @@
no_auth_for_endpoint: '{"Error":"You do not have authorisation to view this endpoint"}'
bad_resource: '{"Error":"You do not have authorisation to view this resource"}'
+ identifier_schemes:
+ ORCID:
+ connect: 'Connect your ORCID'
+ tooltip: 'ORCID provides a persistent digital identifier that distinguishes you from other researchers.'
+
magic_strings:
organisation_types:
funder: 'Funder'
@@ -970,9 +975,4 @@
plans: 'plans'
templates: 'templates'
statistics: 'statistics'
- identifier_schemes:
- ORCID:
- connect_icon: '/assets/orcid.png'
- connect: 'Connect your ORCID'
- tooltip: 'ORCID provides a persistent digital identifier that distinguishes you from other researchers.'
languages:
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index edd1a51..169eefd 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -842,6 +842,11 @@
no_auth_for_endpoint: '{"Error":"You do not have authorisation to view this endpoint"}'
bad_resource: '{"Error":"You do not have authorisation to view this resource"}'
+ identifier_schemes:
+ ORCID:
+ connect: 'Connectez votre compte pour ORCID'
+ tooltip: 'ORCID fournit un identifiant numérique persistant qui vous distingue des autres chercheurs.'
+
magic_strings:
organisation_types:
funder: 'Funder'
@@ -868,8 +873,4 @@
plans: 'plans'
templates: 'templates'
statistics: 'statistics'
- identifier_schemes:
- ORCID:
- connect_icon: '/assets/orcid.png'
- tooltip: 'ORCID fournit un identifiant numérique persistant qui vous distingue des autres chercheurs.'
languages:
diff --git a/config/routes.rb b/config/routes.rb
index 78c801a..34b418f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,11 @@
Rails.application.routes.draw do
- devise_for :users, :controllers => {:registrations => "registrations", :confirmations => 'confirmations', :passwords => 'passwords', :sessions => 'sessions', :omniauth_callbacks => 'users/omniauth_callbacks'} do
+ devise_for :users, controllers: {
+ registrations: "registrations",
+ confirmations: 'confirmations',
+ passwords: 'passwords',
+ sessions: 'sessions',
+ omniauth_callbacks: 'users/omniauth_callbacks'} do
get "/users/sign_out", :to => "devise/sessions#destroy"
end
@@ -8,6 +13,8 @@
get 'auth/shibboleth' => 'users/omniauth_shibboleth_request#redirect', :as => 'user_omniauth_shibboleth'
get 'auth/shibboleth/assoc' => 'users/omniauth_shibboleth_request#associate', :as => 'user_shibboleth_assoc'
+ post '/auth/:provider/callback' => 'sessions#oauth_create'
+
# fix for activeadmin signout bug
devise_scope :user do
get '/users/sign_out' => 'devise/sessions#destroy'
diff --git a/db/migrate/20161024163546_create_user_identifier_scheme.rb b/db/migrate/20161024163546_create_user_identifier_scheme.rb
index 3883c3c..311bc59 100644
--- a/db/migrate/20161024163546_create_user_identifier_scheme.rb
+++ b/db/migrate/20161024163546_create_user_identifier_scheme.rb
@@ -2,8 +2,11 @@
def change
create_table :identifier_schemes do |t|
t.string :name
- t.string :auth_uri
- t.string :user_uri
+ t.string :logo
+ t.string :api_key
+ t.string :api_secret
+ t.string :landing_page_uri
+ t.string :params
t.timestamps
end
diff --git a/db/schema.rb b/db/schema.rb
index cc4fde9..ce3dbc1 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -18,8 +18,8 @@
t.integer "plan_id", limit: 4
t.integer "user_id", limit: 4
t.integer "question_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "answers_options", id: false, force: :cascade do |t|
@@ -33,8 +33,8 @@
t.integer "user_id", limit: 4
t.integer "question_id", limit: 4
t.text "text", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "archived"
t.integer "plan_id", limit: 4
t.integer "archived_by", limit: 4
@@ -46,8 +46,8 @@
t.boolean "published"
t.integer "user_id", limit: 4
t.integer "organisation_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "locale", limit: 255
t.boolean "is_default"
end
@@ -61,8 +61,8 @@
t.integer "plan_id", limit: 4
t.integer "user_id", limit: 4
t.string "format", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "file_types", force: :cascade do |t|
@@ -70,8 +70,8 @@
t.string "icon_name", limit: 255
t.integer "icon_size", limit: 4
t.string "icon_location", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "file_uploads", force: :cascade do |t|
@@ -82,12 +82,12 @@
t.boolean "published"
t.string "location", limit: 255
t.integer "file_type_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "friendly_id_slugs", force: :cascade do |t|
- t.string "slug", limit: 191, null: false
+ t.string "slug", limit: 255, null: false
t.integer "sluggable_id", limit: 4, null: false
t.string "sluggable_type", limit: 40
t.datetime "created_at"
@@ -100,8 +100,8 @@
create_table "guidance_groups", force: :cascade do |t|
t.string "name", limit: 255
t.integer "organisation_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "optional_subset"
t.boolean "published"
end
@@ -116,16 +116,20 @@
create_table "guidances", force: :cascade do |t|
t.text "text", limit: 65535
t.integer "guidance_group_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "question_id", limit: 4
t.boolean "published"
end
create_table "identifier_schemes", force: :cascade do |t|
- t.string "name", limit: 255
- t.string "auth_uri", limit: 255
- t.string "user_uri", limit: 255
+ t.string "name", limit: 255
+ t.string "logo", limit: 255
+ t.string "api_key", limit: 255
+ t.string "api_secret", limit: 255
+ t.string "authorization_uri", limit: 255
+ t.string "landing_page_uri", limit: 255
+ t.string "params", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -141,8 +145,8 @@
t.integer "organisation_id", limit: 4
t.integer "option_id", limit: 4
t.text "text", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "options", force: :cascade do |t|
@@ -150,8 +154,8 @@
t.string "text", limit: 255
t.integer "number", limit: 4
t.boolean "is_default"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "org_token_permissions", force: :cascade do |t|
@@ -164,8 +168,8 @@
create_table "organisation_types", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "organisations", force: :cascade do |t|
@@ -176,13 +180,12 @@
t.string "domain", limit: 255
t.string "wayfless_entity", limit: 255
t.integer "stylesheet_file_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "parent_id", limit: 4
t.boolean "is_other"
t.string "sort_name", limit: 255
t.text "banner_text", limit: 65535
- t.string "logo_file_name", limit: 255
t.integer "region_id", limit: 4
t.integer "language_id", limit: 4
t.string "logo_uid", limit: 255
@@ -195,9 +198,9 @@
t.text "description", limit: 65535
t.integer "number", limit: 4
t.integer "dmptemplate_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "slug", limit: 191
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "slug", limit: 255
end
add_index "phases", ["dmptemplate_id"], name: "index_phases_on_dmptemplate_id", using: :btree
@@ -207,8 +210,8 @@
t.integer "user_id", limit: 4
t.integer "section_id", limit: 4
t.integer "plan_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.datetime "release_time"
end
@@ -216,8 +219,8 @@
t.boolean "locked"
t.integer "project_id", limit: 4
t.integer "version_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "project_groups", force: :cascade do |t|
@@ -225,8 +228,8 @@
t.boolean "project_editor"
t.integer "user_id", limit: 4
t.integer "project_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "project_administrator"
end
@@ -240,9 +243,9 @@
create_table "projects", force: :cascade do |t|
t.string "title", limit: 255
t.integer "dmptemplate_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "slug", limit: 191
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "slug", limit: 255
t.integer "organisation_id", limit: 4
t.string "grant_number", limit: 255
t.string "identifier", limit: 255
@@ -258,8 +261,8 @@
create_table "question_formats", force: :cascade do |t|
t.string "title", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "questions", force: :cascade do |t|
@@ -271,8 +274,8 @@
t.integer "dependency_id", limit: 4
t.text "dependency_text", limit: 65535
t.integer "section_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "question_format_id", limit: 4
t.boolean "option_comment_display", default: true
end
@@ -296,9 +299,9 @@
end
create_table "roles", force: :cascade do |t|
- t.string "name", limit: 191
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.string "name", limit: 255
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "role_in_plans"
t.integer "resource_id", limit: 4
t.string "resource_type", limit: 255
@@ -313,42 +316,42 @@
t.integer "number", limit: 4
t.integer "version_id", limit: 4
t.integer "organisation_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "published"
end
create_table "settings", force: :cascade do |t|
- t.string "var", limit: 191, null: false
+ t.string "var", limit: 255, null: false
t.text "value", limit: 65535
t.integer "target_id", limit: 4, null: false
- t.string "target_type", limit: 191, null: false
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.string "target_type", limit: 255, null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
add_index "settings", ["target_type", "target_id", "var"], name: "index_settings_on_target_type_and_target_id_and_var", unique: true, using: :btree
create_table "splash_logs", force: :cascade do |t|
t.string "destination", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "suggested_answers", force: :cascade do |t|
t.integer "question_id", limit: 4
t.integer "organisation_id", limit: 4
t.text "text", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "is_example"
end
create_table "themes", force: :cascade do |t|
t.string "title", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "locale", limit: 255
end
@@ -358,8 +361,8 @@
end
create_table "token_permission_types", force: :cascade do |t|
- t.string "token_type", limit: 255
- t.text "text_desription", limit: 65535
+ t.string "token_type", limit: 255
+ t.text "text_description", limit: 65535
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -379,43 +382,43 @@
t.integer "user_id", limit: 4
t.integer "organisation_id", limit: 4
t.integer "user_role_type_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "user_role_types", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "user_statuses", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "user_types", force: :cascade do |t|
t.string "name", limit: 255
t.text "description", limit: 65535
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "firstname", limit: 255
t.string "surname", limit: 255
- t.string "email", limit: 191, default: "", null: false
+ t.string "email", limit: 255, default: "", null: false
t.string "orcid_id", limit: 255
t.string "shibboleth_id", limit: 255
t.integer "user_type_id", limit: 4
t.integer "user_status_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "encrypted_password", limit: 255, default: ""
- t.string "reset_password_token", limit: 191
+ t.string "reset_password_token", limit: 255
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", limit: 4, default: 0
@@ -423,15 +426,14 @@
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 255
t.string "last_sign_in_ip", limit: 255
- t.string "confirmation_token", limit: 191
+ t.string "confirmation_token", limit: 255
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
- t.string "invitation_token", limit: 191
+ t.string "invitation_token", limit: 255
t.datetime "invitation_created_at"
t.datetime "invitation_sent_at"
t.datetime "invitation_accepted_at"
t.string "other_organisation", limit: 255
- t.boolean "dmponline3"
t.boolean "accept_terms"
t.integer "organisation_id", limit: 4
t.string "api_token", limit: 255
@@ -458,8 +460,8 @@
t.boolean "published"
t.integer "number", limit: 4
t.integer "phase_id", limit: 4
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
add_index "versions", ["phase_id"], name: "index_versions_on_phase_id", using: :btree
diff --git a/db/seeds.rb b/db/seeds.rb
index 665366c..16afb8f 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -89,8 +89,11 @@
identifier_schemes = {
'orcid' => {
name: 'ORCID',
- auth_uri: '/roadmap/auth/orcid?resource_id=123',
- user_uri: 'https://sandbox.orcid.org/{id}/'
+ landing_page_uri: 'https://sandbox.orcid.org/{id}',
+ logo: '/assets/orcid.png',
+ api_key: 'ABCD1234',
+ api_secret: 'secret',
+ params: '{"member": "false", "sandbox": "false"}'
}
}