similar to: Working around/with Restful Authentication

Displaying 20 results from an estimated 800 matches similar to: "Working around/with Restful Authentication"

2008 Jun 20
15
before_save model callback rspec testing
hi all, i''m learning rspec and i can''t figure out how to test if a callback is executed in a model. my model code is: class User < ActiveRecord::Base before_save :encrypt_password ... def encrypt(password) self.class.encrypt(password, salt) end thanks a lot, cs. -- Posted via http://www.ruby-forum.com/.
2006 Mar 04
4
Two quick newbie questions
2 quick questions regarding authentication ... 1) the flash[:notice] on successful login looks completely wrong to me. How should it be done? def index if request.post? @user = User.new(params[:user]) authentic_user = @user.attempt_login if authentic_user session[:user_id] = authentic_user.id flash[:notice] = ''Login successful! Welcome
2008 Feb 07
1
ActiveRecord 'find_or_initialize_by' dynamic finder bug? Ignoring conditions.
Hello all, I just ran into something that I think is a bug, and I would like to confirm with the core team whether this is expected/desired behavior or if this is a bug that I should file and develop failing tests for (I doubt I have the active record method_missing fu to actually patch it). Test Scenario: I would like to find or initialize a new user and base the find on the users email
2007 Mar 12
2
utc
I''m having a helluva time getting Date.today.utc to resolve - "undefined method `utc'' for #<Date: 4908343/2,0,2299161>" model usage in before_create filter is : activated_at = Date.today.utc I''m not stubbing out Date (should I be? [ stub(Date, :utc => Date.today) didn''t help any ]. The before filter is working fine within the app, but
2011 Oct 14
2
before_save :encrypt_password
I am having a problem finding the best way to make a "before_save :encrypt_password" conditional. I have to at times update user model attributes but each time I do this the password is reencrypted because of the above. I need to differentiate between when the user is first logging in and the password does need to be encrypted, and when they are already logged in and the
2007 May 06
5
Comparing polymorphic property to same object fails
I''ve got a polymorphic association on one table. I assign to it in the controller. This is handling invitations of users to tasks in a task management application. If the user issuing the invitation is the user being invited (ie the user assigned themselves to a task), I want to activate the invitation immediately in the model. The trouble is that this: if self.assignable ==
2006 Apr 12
3
acts_as_authenticated trouble
First off, I''d like to address that I''m n00bs. I''ve read the README and blogs associated with this plugin, and there really isn''t too much documentation. I have the newest version of rails,ruby, and acts_as_authenticated installed. #The setup I set up the acts_as_authenticated in the following manner. *created a table called "accounts" in the
2007 Jul 18
3
Help. Acts_as_Authenticated plugin stops working for me?
Hi, I successfully installed AAA couple days before, and i managed to register a uer with it, with no user activation. but for some strange reason, it stops working for the signup method, with i go to the signup page, press submit, it shows an error page, what''s wrong? here''s the error page. undefined method `activation_code'' for #<User:0x3b6dbd
2007 Oct 15
6
SQL injection with :order, :limit, :group
I know how to avoid SQL injection attacks when you use :conditions User.find :first, :conditions => ["login=?", params[:username]] but how about with :order, :limit or :group? # uh-oh...spaghetti-oh User.find :first, :order => "login; delete from users; select * from users" Pat --~--~---------~--~----~------------~-------~--~----~ You received this message because you
2006 Jul 17
19
updating model
hello, i am writing a simple user login system. when registering a user account, i have two field: password password_confirmation which are validated using validates_presence_of validates_confirmation_of and these are then used to generate a password hash which is stored in my database when i want to update the record (without changing the password and entering new values for password and
2007 Dec 16
2
restful_authentication: update of users' attributes on every page load upon 'Remember me' being enabled?
Hello there, I just noticed a kinda weird thing: if users log in with the ''Remember Me'' option enabled, their records in the db get updated everytime the user reloads a page, because apparently restful_authentication''s code updates the remember_token_expires_at & remember_token attributes for each page load (not only once on the actual login (from cookie).
2010 Oct 11
5
Object lost in memory/trashed?
Hi, I''ve got a problem on which I''ve spent many hours, and I can''t get a clue on what is happening... I hope someone here will be able to help me. Here is the situation : my Rails app uses acts_as_commentable and acts_as_bookmarkable on a Diagram model. Everything''s working OK individually: I can create a comment on a Diagram, bookmark it, and so on. Now,
2006 Jul 02
2
NoMethodError in Unit Test - Rails Newcomer
I''m working on user authentication system to get familiar with rails, and have basically solved most of my apps problems till now. I keep getting the NoMethodError, and can''t understand why. Model: customer.rb class Customer < ActiveRecord::Base ... def self.password=(pass) @password=pass salt = Customer.random_string(10) if !salt? self.hashed_password =
2012 May 26
2
before_create is after_validatation :on => :create , when it should be before_validation :on => :create
In ActiveRecord''s callbacks, methods within a before_create callback are called after the validation, but before the model is created. This was an intentional design decision, but I think it was the wrong one. What do you think? When I think of before_create, I think of before_validation :foo, :on => :create, but, by default, before_create is synonymous with after_validation :foo,
2008 Sep 12
1
restful_authentication rspec failures "Mysql::Error: Incorrect datetime value:"
I am getting 193 failures that all have "Mysql::Error: Incorrect datetime value:" how do i fix this??? i am new to rspec and restful_auth, so if i am doing something wrong, let me know!!! windows xp rails 2.1.1 rails testproject cd testproject # create my databases and edit database.yml git init git submodule add git://github.com/dchelimsky/rspec.git vendor/plugins/ rspec git
2006 Feb 15
1
self in before_create
Hi, I am having a small problem concernig how to access local variables in before_create. I am not sure how to really form this question but here goes: I am wondering why this works def before_create self.last_logged_in = Time.now self.created = Time.now end but this doesn''t def before_create @last_logged_in = Time.now @created = Time.now end The latter fails
2007 May 05
3
DB trigger vs before_create
Hello everyone, I''m having trouble figuring out which approach is better. I have the following tables: products, orders and line_items. Every time an Order is placed, the quantity field in the products table has to be updated for each LineItem in the Order. One option is to use DB triggers which is not as portable as using before_create in the Order model. But with before_create I cannot
2006 Apr 21
2
Using before_create and conflicting setter method...
Hi, I am having trouble using before_create when I have an specialized setter method: before_save :set_campaign_start #----------------------------------------------------------------------- ------- def set_campaign_start self.campaign_start = Time.now end # We want the date to always start at midnight
2006 Feb 15
8
Agile book - getting confusing error
Working through the beginning phase from the Agile book on ''Administration'' undefined method `hashed_password='' for #<User:0xb7911324> ... /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in `method_missing'' #{RAILS_ROOT}/app/models/user.rb:12:in `before_create''
2005 Dec 30
2
before_create question
I have the following models: User, Registration, Event. User has_many Registration, Event has_many Registration, and Registration belongs_to User and Registration. So far, so good. There''s a registration deadline on a Event though, a few days before the Event occurs. So, I have this: class Registration < AR def before_create errors.add_to_base("Registration deadline has