Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix login_tokens

  • Loading branch information...
commit 0b5483a07893a1d86488bdc078fbdb97b99e108b 1 parent 47adea6
Michael Hale authored
View
9 db/migrate/002_fix_login_tokens.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
View
2  test/integration/url_login_test.rb
@@ -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
6 url_login_extension.rb
@@ -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 }
Please sign in to comment.
Something went wrong with that request. Please try again.