authlogic

Rails: Polymorphic User Table a good idea with AuthLogic?

北战南征 提交于 2020-01-25 06:20:46
问题 I have a system where I need to login three user types: customers, companies, and vendors from one login form on the home page. I have created one User table that works according to AuthLogic's example app at http://github.com/binarylogic/authlogic_example. I have added a field called "User Type" that currently contains either 'Customer', 'Company', or 'Vendor'. Note: each user type contains many disparate fields so I'm not sure if Single Table Inheritance is the best way to go (would welcome

Authlogic's current_user object in models

只谈情不闲聊 提交于 2020-01-22 14:12:07
问题 I need to know the ID of the current user in a model: def after_save desc, points=nil, nil if answer_index == daily_question.correct_answer_index desc = I18n.t('daily_question.point_log.description.correct') points=daily_question.points else desc = I18n.t('daily_question.point_log.description.incorrect') end current_user.give_points(:description => desc, :points => points ) end But I guess that is not how it is done? Regards, Jacob 回答1: assuming the user is loggedin you can use UserSession

authlogic flash[:notice] does not show up in cucumber webrat step

拥有回忆 提交于 2020-01-11 13:28:07
问题 I am running BDD steps with cucumber to implement my autlogic login behavior. Scenario: log in Given a registered user: "test@test.com" with password: "p@ssword" exists And I am on the homepage When I follow "Log in" And I fill in "Username" with "test@test.com" And I fill in "Password" with "p@ssword" And I open the page And I press "Login" And I open the page Then I should see "Login successful!" And I should see "Logout" this is my scenario and when I hit Then I should see "Login

Rails, Authlogic without password (registration ok. user_session validation fails)

青春壹個敷衍的年華 提交于 2020-01-11 12:09:32
问题 I am trying to skip the password for Users in Authlogic.. Thanks to SO, I found a solution for creating users User acts_as_authentic do |c| c.validate_password_field = false c.validate_email_field = false end The User_session is still giving a problem - any time I try to log in I get "password cannot be blank".. how to bypass validation on user session? 回答1: Actually found it here: Using Authlogic to authenticate with only a username Just pass a user object instead of login/password

Problem with validates_uniqueness_of

放肆的年华 提交于 2020-01-06 05:19:12
问题 I'm using rails 2.3.5 and Authlogic in our website, and I have been getting errors on the database through hoptoad of users with duplicated emails trying to be saved. The problem is, obviously I have the validates_uniqueness_of :email on the model. On my tests here in development I get the expected validation error and the user is not saved, but in production, I keep getting this errors on the DB layer. I've tested with case sensitive emails and it also validated correctly. I've checked and

RSpec Rails Login Filter

限于喜欢 提交于 2020-01-04 14:14:33
问题 I recently switched started using rspec-rails(2.6.1) with my Rails(3.0.8) app. I'm used to Test::Unit, and I can't seem to get a filter working for my test methods. I like to keep things as DRY as possible, so I'd like to set up a filter that I can call on any test method that will login as an Authlogic user before the test method is called. I tried accomplishing this by using an RSpec filter in spec_helper.rb: config.before(:each, :login_as_admin => true) do post "/user_sessions/create",

RSpec Rails Login Filter

最后都变了- 提交于 2020-01-04 14:14:19
问题 I recently switched started using rspec-rails(2.6.1) with my Rails(3.0.8) app. I'm used to Test::Unit, and I can't seem to get a filter working for my test methods. I like to keep things as DRY as possible, so I'd like to set up a filter that I can call on any test method that will login as an Authlogic user before the test method is called. I tried accomplishing this by using an RSpec filter in spec_helper.rb: config.before(:each, :login_as_admin => true) do post "/user_sessions/create",

changing password with authlogic - validation not catching blank inputs

假装没事ソ 提交于 2020-01-03 18:58:09
问题 I am trying to create a form to allow users to change their password: View: - form_tag change_password_users_path do = error_messages_for :user, :header_message => "Please Try Again", :message => "We had some problems updating your account" %br = label_tag :password, "New password:" = password_field_tag "password" %br = label_tag :password_confirmation, "NConfirm new password:" = password_field_tag "password_confirmation" %br = submit_tag "Update Account" Controller: def change_password @user

using authlogic to auto create users bypassing explicit user registeration

折月煮酒 提交于 2020-01-01 17:06:12
问题 I'm wondering how to go about using Authlogic to auto register a user who chooses to use open id. Right now they have to register first before being able to login in, even if they choose open id, but I'd prefer if they could just login directly provided I get all the necessary details from the open id provider. But I'm not sure how to go about doing this? Would I do it inside my user session controller or is there some fancy way to extend authlogic inside the model? If someone could point me

Problem with sessions, subdomains and authlogic in Rails

戏子无情 提交于 2020-01-01 14:58:36
问题 I've got a rails app with authlogic authentication and a username.domain.com structure built with subdomain-fu. But my session breaks when going from domain.com to username.domain.com. I've tried to add config.action_controller.session = {:domain => '.localhost:3000'} to my development.rb but that seams to break authlogic disabling sign out/sign in. Any suggestions on what to do? Thanks in advance! 回答1: you are having this issue in the development mode but probably wont have this issue in