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



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
48
49
50
# File 'app/controllers/credentials/open_id_controller.rb', line 18

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

  if params[:open_id_complete].nil? && !@login_form.valid?
    set_error_now(p_("MultiAuth", "Please confirm your input."))
    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(p_("MultiAuth", "OpenID authentication credential was successfully added."))
        set_notice("OpenID認証情報を追加しました。")
        redirect_to(:controller => "/credentials", :action => "index")
      else
        set_error_now(p_("MultiAuth", "This OpenID has been already registered."))
        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



53
54
55
# File 'app/controllers/credentials/open_id_controller.rb', line 53

def delete
  # nop
end

#destroyObject

POST /credential/open_id/:open_id_credential_id/destroy



58
59
60
61
62
63
64
# File 'app/controllers/credentials/open_id_controller.rb', line 58

def destroy
  @open_id_credential.destroy

  set_notice(p_("MultiAuth", "OpenID authentication credential was successfully deleted."))
  set_notice("OpenID認証情報を削除しました。")
  redirect_to(:controller => "/credentials")
end

#newObject

GET /credentials/open_id/new



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

def new
  @login_form = OpenIdLoginForm.new
end