Class: Credentials::OpenIdController

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

Overview

OpenID認証情報コントローラ

Instance Method Summary collapse

Instance Method Details

#createObject

POST /credentials/open_id/create GET /credentials/open_id/create



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/credentials/open_id_controller.rb', line 17

def create
  @login_form = OpenIdLoginForm.new(params[:login_form])

  if params[:open_id_complete].nil? && !@login_form.valid?
    set_error_now("入力内容を確認してください。")
    render(:action => "new")
    return
  end

  authenticate_with_open_id(@login_form.openid_url) { |result, identity_url|
    @login_form.openid_url = identity_url
    @status = result.status

    if result.successful?
      @open_id_credential = @login_user.open_id_credentials.find_or_initialize_by_identity_url(identity_url)

      if @open_id_credential.new_record?
        @open_id_credential.save!

        set_notice("OpenID認証情報を追加しました。")
        redirect_to(:controller => "/credentials", :action => "index")
      else
        set_error_now("既に使用されているOpenIDです。")
        render(:action => "new")
      end
    else
      set_error_now(result.message)
      render(:action => "new")
    end
  }
end

#deleteObject

GET /credential/open_id/:open_id_credential_id/delete



50
51
52
# File 'app/controllers/credentials/open_id_controller.rb', line 50

def delete
  # nop
end

#destroyObject

POST /credential/open_id/:open_id_credential_id/destroy



55
56
57
58
59
60
# File 'app/controllers/credentials/open_id_controller.rb', line 55

def destroy
  @open_id_credential.destroy

  set_notice("OpenID認証情報を削除しました。")
  redirect_to(:controller => "/credentials")
end

#newObject

GET /credentials/open_id/new



11
12
13
# File 'app/controllers/credentials/open_id_controller.rb', line 11

def new
  @login_form = OpenIdLoginForm.new
end