Commit c1bb87b1ee5d2b2ab4b1e86abbd14d3a400e1f9c
- Date: Mon May 05 18:57:06 +0000 2008
- Committer: Patrick Aljord (patcito@gmail.com)
- Author: Patrick Aljord (patcito@gmail.com)
- Commit SHA1: c1bb87b1ee5d2b2ab4b1e86abbd14d3a400e1f9c
- Tree SHA1: 86b41e4135747f4b27d15e191ebfaef467ea7646
openid specs pass, yay
renaming openid migration number
Commit diff
| |   |
| 31 | 31 | if result.successful? |
| 32 | 32 | @user = User.find_or_initialize_by_identity_url(identity_url) |
| 33 | 33 | if @user.new_record? |
| 34 | | @user.login = registration['nickname'] |
| 35 | | @user.fullname = registration['fullname'] |
| 36 | | @user.email = registration['email'] |
| 34 | @user.login = registration[:nickname] |
| 35 | @user.fullname = registration[:fullname] |
| 36 | @user.email = registration[:email] |
| 37 | 37 | @user.save! |
| 38 | 38 | @user.activate |
| 39 | 39 | end |
| toggle raw diff |
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -31,9 +31,9 @@ class SessionsController < ApplicationController
if result.successful?
@user = User.find_or_initialize_by_identity_url(identity_url)
if @user.new_record?
- @user.login = registration['nickname']
- @user.fullname = registration['fullname']
- @user.email = registration['email']
+ @user.login = registration[:nickname]
+ @user.fullname = registration[:fullname]
+ @user.email = registration[:email]
@user.save!
@user.activate
end |
| |   |
| 1 | class AddOpenIdAuthenticationTables < ActiveRecord::Migration |
| 2 | def self.up |
| 3 | create_table :open_id_authentication_associations, :force => true do |t| |
| 4 | t.integer :issued, :lifetime |
| 5 | t.string :handle, :assoc_type |
| 6 | t.binary :server_url, :secret |
| 7 | end |
| 8 | |
| 9 | create_table :open_id_authentication_nonces, :force => true do |t| |
| 10 | t.integer :timestamp, :null => false |
| 11 | t.string :server_url, :null => true |
| 12 | t.string :salt, :null => false |
| 13 | end |
| 14 | end |
| 15 | |
| 16 | def self.down |
| 17 | drop_table :open_id_authentication_associations |
| 18 | drop_table :open_id_authentication_nonces |
| 19 | end |
| 20 | end |
| toggle raw diff |
--- /dev/null
+++ b/db/migrate/027_add_open_id_authentication_tables.rb
@@ -0,0 +1,20 @@
+class AddOpenIdAuthenticationTables < ActiveRecord::Migration
+ def self.up
+ create_table :open_id_authentication_associations, :force => true do |t|
+ t.integer :issued, :lifetime
+ t.string :handle, :assoc_type
+ t.binary :server_url, :secret
+ end
+
+ create_table :open_id_authentication_nonces, :force => true do |t|
+ t.integer :timestamp, :null => false
+ t.string :server_url, :null => true
+ t.string :salt, :null => false
+ end
+ end
+
+ def self.down
+ drop_table :open_id_authentication_associations
+ drop_table :open_id_authentication_nonces
+ end
+end |
| |   |
| 1 | 1 | require File.dirname(__FILE__) + '/../spec_helper' |
| 2 | include OpenIdAuthentication |
| 2 | 3 | |
| 3 | 4 | describe SessionsController do |
| 4 | 5 | |
| … | … | |
| 22 | 22 | identity_url = "http://patcito.myopenid.com" |
| 23 | 23 | controller.stub!(:using_open_id?).and_return(true) |
| 24 | 24 | controller.stub!(:successful?).and_return(true) |
| 25 | | controller.stub!(:authenticate_with_open_id).and_yield(result="successfull",identity_url,{:nickname=>"patcito",:email=>"patcito@gmail.com",:fullname=>'Patrick Aljord'}) |
| 25 | controller.stub!(:authenticate_with_open_id).and_yield(Result[:successful],identity_url,registration={:nickname=>"patcito",:email=>"patcito@gmail.com",:fullname=>'Patrick Aljord'}) |
| 26 | post :create, :openid_url => identity_url |
| 26 | 27 | session[:user_id].should_not be(nil) |
| 27 | 28 | response.should be_redirect |
| 28 | 29 | end |
| toggle raw diff |
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -1,4 +1,5 @@
require File.dirname(__FILE__) + '/../spec_helper'
+include OpenIdAuthentication
describe SessionsController do
@@ -21,7 +22,8 @@ describe SessionsController do
identity_url = "http://patcito.myopenid.com"
controller.stub!(:using_open_id?).and_return(true)
controller.stub!(:successful?).and_return(true)
- controller.stub!(:authenticate_with_open_id).and_yield(result="successfull",identity_url,{:nickname=>"patcito",:email=>"patcito@gmail.com",:fullname=>'Patrick Aljord'})
+ controller.stub!(:authenticate_with_open_id).and_yield(Result[:successful],identity_url,registration={:nickname=>"patcito",:email=>"patcito@gmail.com",:fullname=>'Patrick Aljord'})
+ post :create, :openid_url => identity_url
session[:user_id].should_not be(nil)
response.should be_redirect
end |