This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.rpx_token_sessions 'rpx_token_sessions', :controller => "user_sessions", :action => "rpx_create" | |
map.rpx_signup '/rpx_signup', :controller => 'users', :action => 'rpx_new' | |
map.resources :users, :collection => { :rpx_create => :post, :rpx_associate => :post } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserSessionsController < ApplicationController | |
def rpx_create | |
RPXNow.api_key = [YOUR RPX KEY] | |
data = RPXNow.user_data(params[:token], :extended => 'true') | |
if data.blank? | |
@user_session = UserSession.new | |
flash[:error] = "Authentication failed." | |
respond_to do |format| | |
format.html { render :action => :new } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_filter :setup_rpx_api_key, :only => [:rpx_new, :rpx_create, :rpx_associate] | |
protected | |
def setup_rpx_api_key | |
RPXNow.api_key = [YOUR API KEY] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rpx_new | |
# Token should be in the session from UserSessionsController.rpx_create... | |
data = RPXNow.user_data(session[:rpx_token], :extended => 'true') | |
if data.blank? | |
flash[:error] = "Unable to retrieve data from your third-party account. Please try again." | |
redirect_to login_path | |
else | |
identifier = data[:identifier] | |
session[:rpx_identifier] = identifier | |
name = params[:name] || data[:name] || data[:displayName] || data[:nickName] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rpx_new | |
# Token should be in the session from UserSessionsController.rpx_create... | |
data = RPXNow.user_data(session[:rpx_token], :extended => 'true') | |
if data.blank? | |
flash[:error] = "Unable to retrieve data from your third-party account. Please try again." | |
redirect_to login_path | |
else | |
identifier = data[:identifier] | |
session[:rpx_identifier] = identifier | |
name = params[:name] || data[:name] || data[:displayName] || data[:nickName] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
before_filter :setup_rpx_api_key, :only => [:rpx_new, :rpx_create, :rpx_associate] | |
def rpx_new | |
# Token should be in the session from UserSessionsController.rpx_create... | |
data = RPXNow.user_data(session[:rpx_token], :extended => 'true') | |
if data.blank? | |
flash[:error] = "Unable to retrieve data from your third-party account. Please try again." | |
redirect_to login_path | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
RE_LOGIN_OK = /\A\w[\w\.\-_@]+\z/ | |
MSG_LOGIN_BAD = "should use only letters, numbers, and .-_@ please." | |
RE_NAME_OK = /\A[^[:cntrl:]\\<>\/&]*\z/ | |
MSG_NAME_BAD = "avoid non-printing characters and \\><&/ please." | |
acts_as_authentic do |c| | |
# Modify the default Authlogic length/format validations. | |
c.merge_validates_length_of_login_field_options :within => 3..40, :message => "Username too short." | |
c.merge_validates_format_of_login_field_options :with => RE_LOGIN_OK, :message => MSG_LOGIN_BAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddIdentityUrlToUsers < ActiveRecord::Migration | |
def self.up | |
add_column :users, :identity_url, :string | |
add_index :users, :identity_url | |
change_column :users, :login, :string, :default => nil, :null => true | |
change_column :users, :crypted_password, :string, :default => nil, :null => true | |
change_column :users, :password_salt, :string, :default => nil, :null => true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testing |
OlderNewer