Skip to content

Commit

Permalink
Merge 19e1f06 into 5166b95
Browse files Browse the repository at this point in the history
  • Loading branch information
corinnaj committed Jun 8, 2018
2 parents 5166b95 + 19e1f06 commit db0de78
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 7 deletions.
9 changes: 9 additions & 0 deletions app/controllers/users/confirmations_controller.rb
@@ -0,0 +1,9 @@
class Users
class ConfirmationsController < Devise::ConfirmationsController
private

def after_confirmation_path_for(*)
root_path
end
end
end
17 changes: 14 additions & 3 deletions app/models/user.rb
Expand Up @@ -3,6 +3,9 @@
# Table name: users
#
# id :integer not null, primary key
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# email :string default(""), not null
Expand All @@ -16,21 +19,29 @@
# role :string
# sign_in_count :integer default(0), not null
# uid :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_confirmation_token (confirmation_token) UNIQUE
# index_users_on_email (email) UNIQUE
# index_users_on_reset_password_token (reset_password_token) UNIQUE
#

class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, omniauth_providers: [:hpiopenid]
devise :database_authenticatable,
:registerable,
:recoverable,
:rememberable,
:trackable,
:validatable,
:omniauthable,
:confirmable,
omniauth_providers: [:hpiopenid]

has_one :profile
has_many :agreement_letters
Expand Down
2 changes: 2 additions & 0 deletions config/environments/test.rb
Expand Up @@ -34,6 +34,8 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Expand Up @@ -127,7 +127,7 @@
# their account can't be confirmed with the token any more.
# Default is nil, meaning there is no restriction on how long a user can take
# before confirming their account.
# config.confirm_within = 3.days
config.confirm_within = 7.days

# If true, requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Expand Up @@ -41,7 +41,8 @@
end
devise_for :users, :controllers => {
:registrations => "users/registrations",
:omniauth_callbacks => "users/omniauth_callbacks"
:omniauth_callbacks => "users/omniauth_callbacks",
:confirmations => "users/confirmations"
}
resources :users, only: [:index] # index page for devise users
patch 'users/:id/role' => 'users#update_role', as: :update_user_role
Expand Down
15 changes: 15 additions & 0 deletions db/migrate/20180602123530_add_confirmable_to_devise.rb
@@ -0,0 +1,15 @@
class AddConfirmableToDevise < ActiveRecord::Migration[5.1]
def up
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string
add_index :users, :confirmation_token, unique: true
User.all.update_all confirmed_at: DateTime.now
end

def down
remove_columns :users, :confirmation_token, :confirmed_at, :confirmation_sent_at
remove_columns :users, :unconfirmed_email
end
end
7 changes: 6 additions & 1 deletion db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180511192952) do
ActiveRecord::Schema.define(version: 20180602123530) do

create_table "agreement_letters", force: :cascade do |t|
t.integer "user_id", null: false
Expand Down Expand Up @@ -148,6 +148,11 @@
t.string "role"
t.string "provider"
t.string "uid"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/auto_annotate_models.rake
Expand Up @@ -14,7 +14,7 @@ if Rails.env.development?
'position_in_fixture' => 'before',
'position_in_factory' => 'before',
'position_in_serializer' => 'before',
'show_foreign_keys' => 'true',
'show_foreign_keys' => 'false',
'show_complete_foreign_keys' => 'false',
'show_indexes' => 'true',
'simple_indexes' => 'false',
Expand Down
6 changes: 6 additions & 0 deletions spec/factories/users.rb
Expand Up @@ -3,6 +3,9 @@
# Table name: users
#
# id :integer not null, primary key
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# email :string default(""), not null
Expand All @@ -16,11 +19,13 @@
# role :string
# sign_in_count :integer default(0), not null
# uid :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_confirmation_token (confirmation_token) UNIQUE
# index_users_on_email (email) UNIQUE
# index_users_on_reset_password_token (reset_password_token) UNIQUE
#
Expand All @@ -30,6 +35,7 @@
sequence(:email) { |n| "test@example#{n}.com" }
password "test123"
role :pupil
confirmed_at Time.now
factory :user_with_profile do
after(:build) do |user|
build(:profile, user: user)
Expand Down
5 changes: 5 additions & 0 deletions spec/models/user_spec.rb
Expand Up @@ -3,6 +3,9 @@
# Table name: users
#
# id :integer not null, primary key
# confirmation_sent_at :datetime
# confirmation_token :string
# confirmed_at :datetime
# current_sign_in_at :datetime
# current_sign_in_ip :string
# email :string default(""), not null
Expand All @@ -16,11 +19,13 @@
# role :string
# sign_in_count :integer default(0), not null
# uid :string
# unconfirmed_email :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_users_on_confirmation_token (confirmation_token) UNIQUE
# index_users_on_email (email) UNIQUE
# index_users_on_reset_password_token (reset_password_token) UNIQUE
#
Expand Down

0 comments on commit db0de78

Please sign in to comment.