devise

Migrating passwords to Devise

你。 提交于 2019-12-22 10:14:38
问题 I'm migration users database from PHP to Rails. I have already instaled Devise Gem and it is working well now. Also, I have found a hint how to migrate existing users' passwords to Rails I have added old passwords to same encrypted_password field as Devise holds, so when devise fails to auth, checking for old password: # user.rb def valid_password?(password) return false if encrypted_password.blank? require 'digest/sha1' password_salt = 'my_php_framework_salt' Devise.secure_compare(Digest:

Devise authentication error when entering site's root first time

ⅰ亾dé卋堺 提交于 2019-12-22 09:46:58
问题 When user enters our web site's root or logs out, Devise authentication displays "You need to sign in or sign up before continuing" the first time. After page reload this message disappears. Root of our web site is set to controller which has: before_filter :authenticate_user! We need this controller to be the root. How to eliminate this message? 回答1: The correct solution would be to set an authenticated block as noted in the official wiki: https://github.com/plataformatec/devise/wiki/How-To:

Why does Devise keep asking me that the name can't be blank?

走远了吗. 提交于 2019-12-22 09:26:17
问题 I am new to Rails, and I am working with Devise. The problem I am facing is that my form is not updating the name column of the user when they are signing up. I have the name attribute in the data table, but I can't seem to alter it using a form in devise registration. <h2>Sign up</h2> <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> <div><%= f.label :name %><br /> <%= f.text_field :name, :autofocus => true %></div>

Rails expire password within 24 hours

谁说我不能喝 提交于 2019-12-22 08:35:21
问题 In my rails 3.1 application, I want to create and expire random password for users.I am using devise gem for that.Any plugin available for expiring password withing some duration? Or else Please give me some logical advice to implement this feature. Please consider me as a newbie. 回答1: It sounds like you just want to expire the password once. If you're looking to do it at regular intervals (e.g. every couple of months) or if you want to prevent users from re-using passwords, it gets more

Devise allow token authentication on single controller action

我与影子孤独终老i 提交于 2019-12-22 08:27:07
问题 I have an webapplication that uses devise database authentication for all the controllers, however I want to have one controller action where authentication is also done using a token. Can i use devise for this? 回答1: Devise strategies have a valid? method that is called to determine if the strategy should be enabled. This allows you to control available auth strategies on a per controller/action basis. Put this in an initializer: require 'devise/strategies/base' require 'devise/strategies

Rails ActionMailer w/ Devise + Google Apps in Development Mode

ぃ、小莉子 提交于 2019-12-22 08:11:46
问题 I'm trying to configure ActionMailer to send mail from Devise in development mode with my Google Apps account. I've added the following to my config/environments/development.rb file, but it looks like mail is not being sent. Note: this is for Google Apps, not Gmail (but the Gmail servers should work -- they do in my mail client). Anything jump out as strange in my config? config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :enable_starttls_auto => true,

How to log in/out users with Devise in Rails4 testing

一笑奈何 提交于 2019-12-22 07:51:56
问题 I'm trying to ensure proper user access is maintained with Devise in Rails 4, and I'm having a hard time logging a user in in the test suite. The simplest case: require 'test_helper' include Devise::TestHelpers class SiteLayoutTest < ActionDispatch::IntegrationTest def setup @user = users(:test1) end test "logged in should get index" do sign_in @user get users_path assert_response :success assert_select "title", "User Index" end end So far I've not done more really than just implement Devise

Devise flash messages don't show up

筅森魡賤 提交于 2019-12-22 06:55:40
问题 Devise works perfectly in my app except for flash messages from devise.en.yml doesn't get displayed in the view. What am I doing wrong? Below is my sign up page view i have tried both :alert and :notice but not working. Thank you in advance <h2>Sign up</h2> <% if flash[:alert] %> <%=flash[:alert]%> <%end%> <%= form_for(resource,:as=>resource_name,:url => registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> <p><%= f.label :Username %></p> <p><%= f.text_field :username %><

Devise primary key error on postgresql, heroku, Rails 4 [duplicate]

大憨熊 提交于 2019-12-22 05:58:24
问题 This question already has answers here : Rails auto-assigning id that already exists (5 answers) Closed 5 years ago . It is really odd, I'm trying to create a new user by command line and I'm getting this error: User.create :email => "pheewq+1@gmail.com", :password => '123456789', :password_confirmation => '123456789' PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "users_pkey" DETAIL: Key (id)=(37) already exists. 回答1: Try This $ heroku run rails console irb(main)>

Devise primary key error on postgresql, heroku, Rails 4 [duplicate]

孤街浪徒 提交于 2019-12-22 05:58:08
问题 This question already has answers here : Rails auto-assigning id that already exists (5 answers) Closed 5 years ago . It is really odd, I'm trying to create a new user by command line and I'm getting this error: User.create :email => "pheewq+1@gmail.com", :password => '123456789', :password_confirmation => '123456789' PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "users_pkey" DETAIL: Key (id)=(37) already exists. 回答1: Try This $ heroku run rails console irb(main)>