Class: Auth::OpenIdController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/auth/open_id_controller.rb

Overview

OpenID認証 FIXME: 全体的に実装を整理

Instance Method Summary collapse

Instance Method Details

#indexObject

GET /auth/open_id



9
10
11
# File 'app/controllers/auth/open_id_controller.rb', line 9

def index
  session[:user_id] = nil
end

#loginObject

POST /auth/open_id/login GET /auth/open_id/login



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/auth/open_id_controller.rb', line 15

def 
  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
      (result.message)
    end
  }
end