devise

How to let Rails tell mobile applications that users signed in or not?

旧巷老猫 提交于 2019-12-25 02:14:06
问题 I'm developing a Rails application that use devise as the authentication solution. For web applications, users enter username and password in a form, Rails can render different pages after users signed in. Now I'd like to use this framework to support mobile app. In this case, the mobile app needs to know whether the user enters correct username and password. How should devise response to the mobile application, response headers or JSON inside body? Does devise support it? 回答1: You need token

Infamous AbstractController::ActionNotFound - Devise + Rails

五迷三道 提交于 2019-12-25 02:07:25
问题 So I have read how to solve this problem: RSpec Test of Custom Devise Session Controller Fails with AbstractController::ActionNotFound and http://lostincode.net/blog/testing-devise-controllers But under which file do I add these changes is my problem: Under the rspec folder for my registrations_controller I tried this before :each do request.env['devise.mapping'] = Devise.mappings[:user] end require 'spec_helper' describe RegistrationsController do describe "GET 'edit'" do it "should be

Can Facebook Omniauth email address be securely trusted?

孤街醉人 提交于 2019-12-25 02:07:02
问题 I have a traditional Devise user authentication system that simple uses email and password to login. I want to add login with Facebook. I have this mostly working, but I am curious about the security implications of handling an edge case. Let's say this stuff here happens: User is currently unauthenticated, but has an existing account with email "foo@bar.com" User clicks "Login with Facebook", authorizes access from Facebook Facebook calls back to my server showing email as "foo@bar.com" At

Not able to route using after_inactive_sign_up_path_for

微笑、不失礼 提交于 2019-12-25 01:44:59
问题 I overridden RegistrationController my_devise/Registration controller i overridden the following methos: def after_inactive_sign_up_path_for(resource) awaiting_confirmation_path end I also have a new method in my RegistrationController named: def awaiting_confirmation(resource) do tuff.... end My routing file looks likethis: devise_for :accounts, :controllers => { :registrations => "my_devise/registrations"} resources :registration do match "awaiting_confirmation" => "registrations#awaiting

Why does devise me redirect me to /users instead of /users/edit when my account update fails?

前提是你 提交于 2019-12-25 01:44:21
问题 The problem is like this: If I use the default registration controller I get redirected: /users/edit to root when user update succeeds /users/edit to /users when update fails Because the default controller update action looks like this: if resource_updated sign_in resource_name, resource, bypass: true respond_with resource, location: after_update_path_for(resource) else clean_up_passwords resource respond_with resource end after_update_path_for is set by default to root If update fails I get

Integrate layouts with Devise

有些话、适合烂在心里 提交于 2019-12-25 01:39:14
问题 I'm using devise for user auth, however, I want the registration, login, and beta code enter pages to have a layout called 'beta' not the application (default) layout that the rest of the pages have. I normally just change the layout in the controller but there aren't controllers with Devise. Is this not possible and I just have to change the application layout and have a specific layout for all other pages? 回答1: There are controllers in devise and they are easy to customize. Just do the

How do I update a nested resource without passing the data via a form

拟墨画扇 提交于 2019-12-25 01:18:59
问题 Models class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable has_many :roles, :dependent => :destroy, :inverse_of => :user has_many :companies, :through => :roles accepts_nested_attributes_for :roles, :limit => 1, :allow_destroy => true end class Role < ActiveRecord::Base belongs_to :user, :inverse_of => :roles belongs_to :company, :inverse_of => :roles accepts_nested_attributes_for :company end class Company <

How can I move data from one table to another in rails migration?

余生长醉 提交于 2019-12-25 01:18:21
问题 I have set up a rails site with these resources: users(devise) authors I have realised that I need to move all authors over to users table because I am setting up roles for these users as an author now. Currently I have tried the following migration but nothing worked and no data was transferred over to the users table: class MoveAuthorsColumnDataToUsersTable < ActiveRecord::Migration def change Author.find_each do |author| User.find_or_create_by( :username => author.name.downcase.gsub(' ',''

I am using rails-bootstrap-forms gem with devise form_tag

人走茶凉 提交于 2019-12-25 01:14:14
问题 I am using rails-bootstrap-forms gem with devise. How i can customize form_tag with bootstrap with gem rails-bootstrap-forms. My code is <%= form_tag topic_posts_path(@topic) do %> <%= render 'form' %> <%= submit_tag 'Create post' %> <%end%> and my partial _form is <h2>Create new post</h2> <%= label :post, :description %> <%= text_area :post, :description %> I want something like <div class="form-group"> <label for="xyz">xyz</label> <input type="email" class="form-control" id="xyz"

RSpec with devise - only the first test is logged in

本小妞迷上赌 提交于 2019-12-25 00:56:10
问题 I'm trying to write a rspec feature test for a page where the user must be logged in with devise. RSpec.feature "User sees items" do before(:context) do .. login_as(@user, :scope => :user) end after(:each) do Warden.test_reset! end it "sees 3 items" do create_items 1, 2 visit root_path expect(page).to have_css("#total", text: "3") end it "sees 7 items" do create_items 3, 4 visit root_path expect(page).to have_css("#total", text: "7") end end In my rails_helper I'm including include Warden: