Sha256: e5150b56672f405077741466feb511d2c37a60f5f1c8b835b1d23c9cff9526ad

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

# -*- coding: utf-8 -*-

# OpenID認証
# FIXME: 全体的に実装を整理
class Auth::OpenIdController < ApplicationController
  verify_method_post :only => [:login]

  # GET /auth/open_id
  def index
    session[:user_id] = nil
  end

  # POST /auth/open_id/login
  # GET  /auth/open_id/login
  def login
    openid_url = params[:openid_url]

    authenticate_with_open_id(openid_url) { |result, identity_url, sreg|
      if result.successful?
        @open_id_credential = OpenIdCredential.find_by_identity_url(identity_url)
        if @open_id_credential
          @open_id_credential.login!
          session[:user_id] = @open_id_credential.user_id
          set_notice(p_("MultiAuth", "Logged in successfully."))
          redirect_to(root_path)
        else
          set_notice(p_("MultiAuth", "This OpenID has not been registered yet."))
          redirect_to(:controller => "signup/open_id", :action => "index")
        end
      else
        failed_login(result.message)
      end
    }
  end

  private

  def failed_login(message)
    set_error(message)
    redirect_to(root_path)
  end

end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
multi_auth-0.2.0 app/controllers/auth/open_id_controller.rb
okkez-multi_auth-0.1.0 app/controllers/auth/open_id_controller.rb
multi_auth-0.1.0 app/controllers/auth/open_id_controller.rb
okkez-multi_auth-0.0.7 app/controllers/auth/open_id_controller.rb
multi_auth-0.0.7 app/controllers/auth/open_id_controller.rb
okkez-multi_auth-0.0.6 app/controllers/auth/open_id_controller.rb
multi_auth-0.0.6 app/controllers/auth/open_id_controller.rb
okkez-multi_auth-0.0.5 app/controllers/auth/open_id_controller.rb
multi_auth-0.0.5 app/controllers/auth/open_id_controller.rb