Permalink
Browse files

fix login_tokens

  • Loading branch information...
1 parent 47adea6 commit 0b5483a07893a1d86488bdc078fbdb97b99e108b Michael Hale committed Jun 30, 2009
Showing with 14 additions and 3 deletions.
  1. +9 −0 db/migrate/002_fix_login_tokens.rb
  2. +0 −2 test/integration/url_login_test.rb
  3. +5 −1 url_login_extension.rb
@@ -0,0 +1,9 @@
+class FixLoginTokens < ActiveRecord::Migration
+ def self.up
+ remove_column :users, :login_tokens
+ add_column :users, :login_tokens, :string
+ end
+
+ def self.down
+ end
+end
@@ -12,9 +12,7 @@ def test_login_succeeds
get "/login/GoodToken/#{redirect_url.encode}"
assert_redirected_to redirect_url
user.reload
-
assert_equal [], user.login_tokens
assert_equal user, controller.send(:current_user)
- assert false
end
end
View
@@ -9,8 +9,12 @@ class UrlLoginExtension < Radiant::Extension
def activate
User.class_eval do
- serialize :login_tokens, Array
+ serialize(:login_tokens, Array)
+ def login_tokens
+ self[:login_tokens] ||= []
+ end
+
def generate_token(size)
chars = ((' '[0]..'~'[0]).to_a.collect{|e| e.chr} - %w(' " \\ ` /))
(0...size).inject(''){ |memo,_| memo << chars.sort_by{rand}.first }

0 comments on commit 0b5483a

Please sign in to comment.