#<AccountSession: no credentials provided> adds errors to the form on :new action
Creating a new instance automatically loads errors into @base and populates those errors on my sign in form:
(rdb:1) @account_session = AccountSession.new
<AccountSession: no credentials provided>
(rdb:1) @account_session.errors
<Authlogic::Session::Validation::Errors:0x213cc78 @errors={}, @base=#<AccountSession: no credentials provided>>
Is this correct behavior or am I missing something?
Gavin
You should do something like that: @account_session = AccountSession.new(:username => 'my_username', :password => 'password')
Doing that on the :new action will populate the form with (incorrect) data, which is not what we want on :new. We want the form to be blank. Calling AccountSession.new(:username => ' ', :password => ' ') gives the same "no credentials..." error. I'm sure the solution is simple, but I don't see it.
Did you ever figure this out? I'm having a very similar problem.
I agree that I am experiencing the same issue. I am currently running rails 3 beta 3 and authlogic 2.1.4.
# user_sessions_controller.rb
class UserSessionsController < ApplicationController
def new
# offending line
@user_session = UserSession.new
end
end
# error message
ActionView::Template::Error (undefined method `to_key' for #) on line #2 of /Users/leonard/Sites/media_six/single_sign_on/app/views/user_sessions/new.html.erb:
1:
2: <%= form_for @user_session do |f| %>
3: <%= render "shared/error_messages", :target => @user_session %>
4:
5: <%= field_set_tag 'login' do %>
coop: me too, on my r3b3 test project.
same here
I had problems when I tried to do it without a user id / login field. I wanted multiple email addresses associated with a single account/password, and authlogic does not support that. Make sure you have some sort of login field.
is any one find the solution? i am facing the same...
I managed to get mine working by changing form_for tag to this:
<% form_for :user_session, @user_session, :url => { :action => "create" } do |f| %>
Hope this helps.
@plusjade
Thanks, that is what is needed to display default form errors on the login template.
To keep the form from repopulating the login field. I added the following to UserSessionsController::create @user_session.login = nil render :action => :new
Closing after six years with no activity. If this is still a problem in the latest version (currently 3.5.0), please let us know and we'll be happy to re-open the issue.