Class: Signup::OpenIdController

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

Overview

OpenID認証情報サインアップ FIXME: 全体的に実装を整理

Instance Method Summary collapse

Instance Method Details

#authenticateObject

POST /signup/open_id/authenticate GET /signup/open_id/authenticate



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

def authenticate
  @openid_url = params[:openid_url]

  failed = proc { |message|
    flash[:error] = message
    redirect_to(:action => "index")
  }

  authenticate_with_open_id(@openid_url) { |result, identity_url, sreg|
    if result.successful?
      if OpenIdCredential.exists?(:identity_url => identity_url)
        failed["指定されたOpenIDは既に登録されているため、利用できません。"]
      else
        session[:identity_url] = identity_url
        redirect_to(:action => "authenticated")
      end
    else
      failed[result.message]
    end
  }
end

#authenticatedObject

GET /signup/open_id/authenticated



37
38
39
# File 'app/controllers/signup/open_id_controller.rb', line 37

def authenticated
  @identity_url = session[:identity_url]
end

#createObject

POST /signup/open_id/create



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/signup/open_id_controller.rb', line 42

def create
  @identity_url = session[:identity_url]

  @user = MultiAuth.user_model_class.new
  @credential = @user.open_id_credentials.build
  @credential.identity_url = @identity_url

  @user.save!

  # FIXME: ログイン状態にしないように変更
  session[:identity_url] = nil
  session[:user_id]      = @user.id

  redirect_to(:action => "created")
end

#createdObject

GET /signup/open_id/created



59
60
61
# File 'app/controllers/signup/open_id_controller.rb', line 59

def created
  # nop
end

#indexObject

GET /signup/open_id



7
8
9
10
# File 'app/controllers/signup/open_id_controller.rb', line 7

def index
  session[:identity_url] = nil
  @openid_url = nil
end