warden

Devise - single sign in form for multiple users

倾然丶 夕夏残阳落幕 提交于 2019-12-01 05:37:55
I have two Devise models, User and Business; I would like both to be able to sign in using a single sign in form. I am using backbone js and I have a customized view so the view is not a concern. An ajax request is used for the login, it works for users as expected but not for businesses. I have searched google and come across a few solutions that mention using STI to solve this, but the project is very much done and I can't make such a change now. I was thinking along the lines of overriding the Devise sessions controller and: Check if the given email address is a User, then authenticate the

Devise - single sign in form for multiple users

你。 提交于 2019-12-01 03:57:09
问题 I have two Devise models, User and Business; I would like both to be able to sign in using a single sign in form. I am using backbone js and I have a customized view so the view is not a concern. An ajax request is used for the login, it works for users as expected but not for businesses. I have searched google and come across a few solutions that mention using STI to solve this, but the project is very much done and I can't make such a change now. I was thinking along the lines of overriding

How to access session from Warden/Devise after_authentication callback in Rails

怎甘沉沦 提交于 2019-11-30 19:04:54
I'm trying to access the current session from Warden's after_authenticate callback (running underneath Devise) in Rails 3. At the top of my application controller I want to do something like: Warden::Manager.after_authentication do |user,auth,opts| user.associate_with_ids(session[:pending_ids]) end The ultimate goal is to take a list of record IDs that were stored in the session before sign up and associate them with the user model after sign in. Any help would be much appreciated. polmiro " auth.session " get/sets the data in the session key " warden.user.#{scope}.session ". Supposing you had

Sinatra Warden with existing Ruby on Rails application that uses Devise

纵饮孤独 提交于 2019-11-30 14:51:28
I am trying to split my current Ruby on Rails 3 web-application and it's web-services (API). My web-application is running on Heroku and implements API as a namespaced route within my application. For example /events returns a HTML page and /api/v1/events returns a JSON data. According to some best practices , I want to split those into two different applications. I have chosen Sinatra to implement the API application. It works now for simple requests where authentication is not required. My Ruby on Rails 3 application is using Devise to authenticate users. There's also ability to login with

Devise - Sign In with Ajax

北城以北 提交于 2019-11-30 12:16:31
问题 Is here any possibility to modify devise SessionsController for ajax communication? Edit I found the solution, and posted it into answers, thanks 回答1: 1. Generate Devise controllers so we can modify it rails g devise:controllers Now we have all controllers in the app/controllers/[model] directory 2. Edit routes.rb Let's set Devise to use our modified SessionsController First add this code (of course change :users to your devise model) into config/routes.rb devise_for :users, controllers: {

How do I login a user with devise?

流过昼夜 提交于 2019-11-30 11:47:13
问题 I have my rails application and I am running into a major issue with devise. I have a controller: class Users::SessionsController < Devise::SessionsController prepend_before_filter :require_no_authentication, :only => [ :new, :create ] include Devise::Controllers::InternalHelpers def new clean_up_passwords(build_resource) respond_to do |format| format.html { render :layout => "sessions" } format.mobile end end # POST /resource/sign_in def create resource = User.find_by_email(params[:user][

How to access session from Warden/Devise after_authentication callback in Rails

最后都变了- 提交于 2019-11-30 03:15:18
问题 I'm trying to access the current session from Warden's after_authenticate callback (running underneath Devise) in Rails 3. At the top of my application controller I want to do something like: Warden::Manager.after_authentication do |user,auth,opts| user.associate_with_ids(session[:pending_ids]) end The ultimate goal is to take a list of record IDs that were stored in the session before sign up and associate them with the user model after sign in. Any help would be much appreciated. 回答1: "

uncaught throw :warden in Devise Testing

China☆狼群 提交于 2019-11-29 11:07:34
问题 I have just begun with testing Devise. I am unable to understand of why i am getting this error :: Failure/Error: subject.current_user.should_not be_nil ArgumentError: uncaught throw :warden This is the code in my spec :: require "spec_helper" describe Devise::PasswordsController do include Devise::TestHelpers before(:each) do user = Factory(:user) @request.env["devise.mapping"] = Devise.mappings[:user] sign_in user end it "should have a current user" do subject.current_user.should_not be_nil

Devise warden error thrown for authenticate_user in functional Rails test

寵の児 提交于 2019-11-29 02:23:40
I have a resource where the new action requires a user to be logged in to view. If a user tries to create a new resource without being logged in, they are redirected (302'd) to the login page. My functional test looks like this: test "should not get new unless logged in" do get :new assert_response :redirect end The stacktrace looks something like this: ArgumentError: uncaught throw :warden /.../gems/warden-1.1.1/lib/warden/proxy.rb:114:in `throw' /.../gems/ruby-1.9.2-p318/gems/warden-1.1.1/lib/warden/proxy.rb:114:in `authenticate!' /.../gems/ruby-1.9.2-p318/gems/devise-2.0.4/lib/devise

Why is my RSpec not loading Devise::Test::ControllerHelpers?

▼魔方 西西 提交于 2019-11-28 19:06:49
I'm using Rails 5, and Devise 3.5.1. Going through a nice (older) book about creating/testing an API, which uses Devise authentication. It was written before Rails 5, so I chose not to use the new api-only version. Here's my test... #/spec/controllers/api/v1/users_controller_spec.rb require 'rails_helper' describe Api::V1::UsersController, :type => :controller do before(:each) { request.headers['Accept'] = "application/vnd.marketplace.v1" } describe "GET #show" do before(:each) do @user = FactoryGirl.create :user get :show, params: {id: @user.id}, format: :json end it "returns the information