Sha256: 56eb633f0a69a2a9324e4bc17212960c498e7c8dafed7b3daf2bb8db06574a56

Contents?: true

Size: 1.22 KB

Versions: 25

Compression:

Stored size: 1.22 KB

Contents

# Controller for handling the login, logout process for "users" of our
# little server.  Users have no password.  This is just an example.

require 'openid'

class LoginController < ApplicationController

  layout 'server'

  def base_url
    url_for(:controller => 'login', :action => nil, :only_path => false)
  end

  def index
    response.headers['X-XRDS-Location'] = url_for(:controller => "server",
                                                  :action => "idp_xrds",
                                                  :only_path => false)
    @base_url = base_url
    # just show the login page
  end

  def submit
    user = params[:username]

    # if we get a user, log them in by putting their username in
    # the session hash.
    unless user.nil?
      session[:username] = user unless user.nil?
      session[:approvals] = []
      flash[:notice] = "Your OpenID URL is <b>#{base_url}user/#{user}</b><br/><br/>Proceed to step 2 below."
    else
      flash[:error] = "Sorry, couldn't log you in. Try again."
    end
    
    redirect_to :action => 'index'
  end

  def logout
    # delete the username from the session hash
    session[:username] = nil
    session[:approvals] = nil
    redirect_to :action => 'index'
  end

end

Version data entries

25 entries across 25 versions & 4 rubygems

Version Path
ruby-openid-2.9.2 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.9.1 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.8.0 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.7.0 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.6.0 examples/rails_openid/app/controllers/login_controller.rb
pelle-ruby-openid-2.1.8 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.5.0 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.4.0 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.3.0 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.2.3 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.2.2 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.2.1 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.2.0 examples/rails_openid/app/controllers/login_controller.rb
entp-ruby-openid-2.2 examples/rails_openid/app/controllers/login_controller.rb
nov-ruby-openid-2.1.9 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.1.8 examples/rails_openid/app/controllers/login_controller.rb
pelle-ruby-openid-2.1.9 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.1.7 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.0.2 examples/rails_openid/app/controllers/login_controller.rb
ruby-openid-2.1.4 examples/rails_openid/app/controllers/login_controller.rb