devise

Testing that Devise is re-sending confirmation instructions email in a background worker

房东的猫 提交于 2020-02-25 01:28:27
问题 I want to send Devise confirmation instructions to users a second time if they haven't confirmed within two days of signing up, however I can't seem to get my success case test to pass. Background worker (runs once a day): class ResendConfirmationWorker include Sidekiq::Worker sidekiq_options queue: :resend_confirmation, retry: false def perform d = Time.zone.now - 2.days users = User.where.not(confirmation_sent_at: nil) .where(confirmed_at: nil) .where(created_at: d.beginning_of_day..d.end

How do I redirect after_sign_up_path_for to a create action of another controller?

不羁岁月 提交于 2020-02-06 07:54:10
问题 So I have OrdersController#Create , that I would like the user to be redirected to right after they register (so it can do some post-registration stuff). Before I implemented the registration part of this workflow, this is what the link_to for that resource looked like: <%= link_to 'Submit to Scheduling', orders_path(cart_id: @cart), method: :post, data: { confirm: "Are you sure?" }, class: "primary button btn" %> So basically, I would like to achieve the above functionality (including

Work around for issue multiple user models with devise_token_auth and active_model_serializers?

自闭症网瘾萝莉.ら 提交于 2020-02-05 04:08:13
问题 The combination of multiple user models (User, Admin, and Master) with devise_token_auth does not successfully set the Response Headers (uid, token, etc.) upon login with non "User" models (Admin and Master); however, User model works. The cause looks to be the default serialization_scope (:current_user) in active_model_serializers/lib/action_controller/serialization.rb:18. Is there a way to set the serialization_scope, or do I need to override the controllers? Environment: Rails 4.2.6 AMS 10

What's the correct configuration line to get devise, omniauth and google working?

爱⌒轻易说出口 提交于 2020-02-03 23:41:53
问题 I've looked through the documentation and I can't figure out the specific line I'm meant to use to get devise + omniauth + google working together nicely. This strategy file suggests there's an easy way of doing it but I can't find an example. https://github.com/intridea/omniauth/blob/master/oa-oauth/lib/omniauth/strategies/google.rb At the moment I'm using the line below in the devise.rb initializer file. config.omniauth :google, GOOGLE_APP_ID, GOOGLE_SECRET_KEY but I'm pretty sure it's

Allow only specific emails to register in Rails app (Devise)

拥有回忆 提交于 2020-02-03 08:27:11
问题 I am using Devise to authenticate and register users in my Rails app. However, I only want users who have an email with a specific ending to be able to sign up and access it (let's say @xyz.com). What do I need to do to reflect that? 回答1: If you want to restrict users access after the registration use before_filter: before_filter :verify_email private def verify_email (redirect_to(root_path) unless current_user.email.include?('@xyz.com') end Edit: if you want to restrict registration you

NoMethodError in Devise::SessionsController#create undefined method `current_sign_in_at'

南楼画角 提交于 2020-02-03 07:46:06
问题 I am getting the following error when I try to sign in in my rails app. I used devise for authentication. My error is NoMethodError in Devise::SessionsController#create undefined method `current_sign_in_at' My user model is models/user.rb devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable attr_accessible :admin,:first_name, :last_name, :profile_name, :college_name, :email, :password, :password_confirmation, :remember_me,

how to add admin with devise in ROR

孤街醉人 提交于 2020-02-02 16:11:49
问题 I am using devise gem and i wanna to create admin rails g migration add_admin_to_user in the db def change add_column :users, :admin , :boolean , {default: false} end def user def admin? user=User.create(email: "info@presale.ca",password: "12345678") user.admin=true user user.save admin end end in the index page <% if current_user && current_user.admin? %> <% end %> theres something wrong in the def user how to fix it please? 回答1: There's a few things that aren't ideal: Your attribute User

Configure Devise Allow Same Email For Multiple Accounts

故事扮演 提交于 2020-02-02 10:12:12
问题 We have users that want to use the same email address for multiple accounts. Our rails app uses omniauth-twitter gem with Devise to authenticate users. When users sign up, email is required but it is not used for authentication. How do we configure Devise to allow users to use same email when signing up for multiple accounts without getting "email has already been taken" validation error? 回答1: You can simply remove :validatable from the model devise options. Validatable creates all needed

Rails 4 with MailCatcher and Devise gems

前提是你 提交于 2020-02-02 06:50:46
问题 I have an app with gem Devise. I need to confirm registration by email. In config/environment.rb I added this ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :domain => "gmail.com", :authentication => 'plain', :user_name => "myappname@gmail.com", :password => "mypassword" } In config/environment/development.rb added: config.action_mailer.default_url_options = { :host => 'localhost:3000' } config.action_mailer.delivery

Rails 4 - Devise: getting ActionController::UnknownFormat on signup

醉酒当歌 提交于 2020-02-01 03:48:10
问题 I have a Rails 4.2.3 app where I use Devise for user authentication. I present my signup form in a Bootstrap modal. I have implemented it similar to: https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app. On signup I keep getting this error: Completed 406 Not Acceptable in 512033ms (ActiveRecord: 5.8ms) ActionController::UnknownFormat (ActionController::UnknownFormat) And I'm not sur how to fix it. I use custom controllers for sessions and