OSDN Git Service

upgrade devise to 3
authoryasushiito <yas@pen-chan.jp>
Thu, 11 Jun 2015 06:33:15 +0000 (15:33 +0900)
committeryasushiito <yas@pen-chan.jp>
Thu, 11 Jun 2015 06:33:15 +0000 (15:33 +0900)
Gemfile
app/models/admin.rb
app/models/demand_user.rb
app/models/user.rb
config/initializers/devise.rb
config/locales/devise.en.yml
db/migrate/20111206092734_devise_create_admins.rb
db/migrate/20120306231650_devise_create_users.rb
db/migrate/20121123051900_devise_create_demand_users.rb

diff --git a/Gemfile b/Gemfile
index 90b68a2..8951587 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,8 @@
 source 'https://rubygems.org'
 
 gem 'rails', '~> 3.2.0'
-gem 'devise', '=1.5.2'
+gem 'devise'
+# gem 'devise_token_auth'
 gem 'rest-client'
 gem 'underscore-rails'
 # gem 'backbone-rails'
index abff349..0788a94 100644 (file)
@@ -2,12 +2,12 @@ class Admin < ActiveRecord::Base
   # Include default devise modules. Others available are:
   # , :encryptable, :lockable, :timeoutable and :omniauthable, :confirmable
   devise :database_authenticatable, :registerable,
-         :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
+         :recoverable, :rememberable, :trackable, :validatable 
 
   # Setup accessible (or protected) attributes for your model
   attr_accessible :email, :password, :password_confirmation, :remember_me
   
-  def active_for_authentication?\r
+  def active_for_authentication?
     super && (self.approve == 1)
   end
 
index 64fe093..6c2a2c0 100644 (file)
@@ -4,8 +4,7 @@ class DemandUser < ActiveRecord::Base
   # Include default devise modules. Others available are:
   # :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
   devise :database_authenticatable, :registerable,
-         :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
-
+         :recoverable, :rememberable, :trackable, :validatable 
   # Setup accessible (or protected) attributes for your model
   attr_accessible :email, :password, :password_confirmation, :remember_me
   
index d59f35e..20c2250 100644 (file)
@@ -5,7 +5,7 @@ class User < ActiveRecord::Base
   # Include default devise modules. Others available are:
   # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
   devise :database_authenticatable, :registerable,
-         :recoverable, :rememberable, :trackable, :token_authenticatable, :validatable#, :confirmable
+         :recoverable, :rememberable, :trackable,  :validatable#, :confirmable
 
   # Setup accessible (or protected) attributes for your model
   attr_accessible :id, :name, :password, :password_confirmation, :remember_me , :email
index 196e97d..33a6b79 100644 (file)
@@ -6,7 +6,7 @@ Devise.setup do |config|
   # note that it will be overwritten if you use your own mailer class with default "from" parameter.
   config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
 config.sign_out_via = :get
-
+  config.secret_key = 'ef21afb7caa18dd6b587e999417c281dbcafdfa132cdb38d08bd4150b763bda62bd5739df69d0d85f514f970608e2efff7fe92a5543ca546ce614ee188bc0177'
   # Configure the class responsible to send e-mails.
   # config.mailer = "Devise::Mailer"
 
@@ -95,7 +95,7 @@ config.sign_out_via = :get
 
   # If true, uses the password salt as remember token. This should be turned
   # to false if you are not using database authenticatable.
-  config.use_salt_as_remember_token = true
+  config.use_salt_as_remember_token = true
 
   # Options to be passed to the created cookie. For instance, you can set
   # :secure => true in order to force SSL only cookies.
@@ -158,7 +158,7 @@ config.sign_out_via = :get
 
   # ==> Configuration for :token_authenticatable
   # Defines name of the authentication token params key
-config.token_authentication_key = :auth_token
+config.token_authentication_key = :auth_token
 
   # If true, authentication through token does not store user in session and needs
   # to be supplied on each request. Useful if you are using the token as API token.
index 79b3d5e..0f3b414 100644 (file)
@@ -35,11 +35,12 @@ en:
       confirmed: 'Your account was successfully confirmed. You are now signed in.'
     registrations:
       signed_up: 'Welcome! You have signed up successfully.'
-      inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
       updated: 'You updated your account successfully.'
       destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
       reasons:
-        inactive: 'inactive'
+        signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
+        signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
+        signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
         unconfirmed: 'unconfirmed'
         locked: 'locked'
     unlocks:
index 03fb591..6e94741 100644 (file)
@@ -1,15 +1,39 @@
 class DeviseCreateAdmins < ActiveRecord::Migration
   def change
     create_table(:admins) do |t|
-      t.database_authenticatable :null => false
-      t.recoverable
-      t.rememberable
-      t.trackable
+      ## Database authenticatable
+      t.string :email,              :null => false, :default => ""
+      t.string :encrypted_password, :null => false, :default => ""
+
+      ## Recoverable
+      t.string   :reset_password_token
+      t.datetime :reset_password_sent_at
+
+      ## Rememberable
+      t.datetime :remember_created_at
+
+      ## Trackable
+      t.integer  :sign_in_count, :default => 0
+      t.datetime :current_sign_in_at
+      t.datetime :last_sign_in_at
+      t.string   :current_sign_in_ip
+      t.string   :last_sign_in_ip
 
       # t.encryptable
-      t.confirmable
-      # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
-      t.token_authenticatable
+      ## Confirmable
+      t.string   :confirmation_token
+      t.datetime :confirmed_at
+      t.datetime :confirmation_sent_at
+      t.string   :unconfirmed_email # Only if using reconfirmable
+
+      ## Lockable
+      # t.integer  :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
+      # t.string   :unlock_token # Only if unlock strategy is :email or :both
+      # t.datetime :locked_at
+
+      # Token authenticatable
+      t.string :authentication_token
+
       t.integer :approve, :null => false, :default => 0
 
       t.timestamps
index 915a976..0f3195a 100644 (file)
@@ -1,15 +1,38 @@
 class DeviseCreateUsers < ActiveRecord::Migration
   def change
     create_table(:users) do |t|
-      t.database_authenticatable :null => false
-      t.recoverable
-      t.rememberable
-      t.trackable
-      t.token_authenticatable
-      t.confirmable
+      ## Database authenticatable
+      t.string :email,              :null => false, :default => ""
+      t.string :encrypted_password, :null => false, :default => ""
+
+      ## Recoverable
+      t.string   :reset_password_token
+      t.datetime :reset_password_sent_at
+
+      ## Rememberable
+      t.datetime :remember_created_at
+
+      ## Trackable
+      t.integer  :sign_in_count, :default => 0
+      t.datetime :current_sign_in_at
+      t.datetime :last_sign_in_at
+      t.string   :current_sign_in_ip
+      t.string   :last_sign_in_ip
 
       # t.encryptable
-      # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
+      ## Confirmable
+      t.string   :confirmation_token
+      t.datetime :confirmed_at
+      t.datetime :confirmation_sent_at
+      t.string   :unconfirmed_email # Only if using reconfirmable
+
+      ## Lockable
+      # t.integer  :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
+      # t.string   :unlock_token # Only if unlock strategy is :email or :both
+      # t.datetime :locked_at
+
+      # Token authenticatable
+      t.string :authentication_token
 
 
       t.timestamps
index 13410a5..45af068 100644 (file)
@@ -1,15 +1,38 @@
 class DeviseCreateDemandUsers < ActiveRecord::Migration
   def change
     create_table(:demand_users) do |t|
-      t.database_authenticatable :null => false
-      t.recoverable
-      t.rememberable
-      t.trackable
+      ## Database authenticatable
+      t.string :email,              :null => false, :default => ""
+      t.string :encrypted_password, :null => false, :default => ""
+
+      ## Recoverable
+      t.string   :reset_password_token
+      t.datetime :reset_password_sent_at
+
+      ## Rememberable
+      t.datetime :remember_created_at
+
+      ## Trackable
+      t.integer  :sign_in_count, :default => 0
+      t.datetime :current_sign_in_at
+      t.datetime :last_sign_in_at
+      t.string   :current_sign_in_ip
+      t.string   :last_sign_in_ip
 
       # t.encryptable
-      t.confirmable
-      # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
-      t.token_authenticatable
+      ## Confirmable
+      t.string   :confirmation_token
+      t.datetime :confirmed_at
+      t.datetime :confirmation_sent_at
+      t.string   :unconfirmed_email # Only if using reconfirmable
+
+      ## Lockable
+      # t.integer  :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
+      # t.string   :unlock_token # Only if unlock strategy is :email or :both
+      # t.datetime :locked_at
+
+      # Token authenticatable
+      t.string :authentication_token
 
 
       t.timestamps