A
A
Andrey Andreev2016-04-25 23:46:51
Ruby on Rails
Andrey Andreev, 2016-04-25 23:46:51

Why does the Device log out after changing the password?

Hello, I can not get the Device gem, I will be grateful for any help.
The administrator can change his email and password.
If he changes the password, then he throws it out on the authorization page.
If the email changes, then everything is fine.
How to disable this feature?
Devise 3.5.6
Controller:

def update_profile
    if current_admin.update(admin_params)
      redirect_to dashboard_settings_path
    else
      flash[:errors] = current_admin.errors.full_messages.to_sentence
      render :index
    end
  end
  ....
  private
  def admin_params
    params.require(:admin).permit(:email, :password)
  end

Model:
# == Schema Information
#
# Table name: admins
#
#  id                     :integer          not null, primary key
#  email                  :string           default(""), not null
#  encrypted_password     :string           default(""), not null
#  reset_password_token   :string
#  reset_password_sent_at :datetime
#  remember_created_at    :datetime
#  sign_in_count          :integer          default("0"), not null
#  current_sign_in_at     :datetime
#  last_sign_in_at        :datetime
#  current_sign_in_ip     :string
#  last_sign_in_ip        :string
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#

class Admin < ActiveRecord::Base
  # :confirmable, :lockable, :timeoutable  :omniauthable :registerable, :validatable :recoverable, :trackable
  devise :database_authenticatable, :rememberable
end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey R, 2016-04-25
@b0nn1e

Before the redirect you need to add
sign_in(current_admin, bypass: true)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question