deviseとomniauth-google-oauth2を利用してログインは可能になったのですが、
ログイン後の表示がdeviseのメールアドレスとパスワードのログイン画面となってしまい、ログイン完了のviewが表示されません。
ルーティングの問題でしょうか。どのようにしたら、ログイン完了画面が表示されるのか教えていただけると幸いです。
ちなみに、下記のサイトを参照しました。
Qiita - deviseとomniauthを使ったGoogle認証の流れ
コントローラ
user_controller.rb
class UserController < ApplicationController def user_cal end end
welcome_controller.rb
class WelcomeController < ApplicationController def index end end
model
user.rb
class User < ApplicationRecord devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable def self.find_for_google_oauth2(auth) user = User.where(email: auth.info.email).first unless user user = User.create(name: auth.info.name, provider: auth.provider, uid: auth.uid, email: auth.info.email, token: auth.credentials.token, password: Devise.friendly_token[0, 20]) end user end end
view
welcome/index.html.erb
<%= link_to "Googleでログイン", user_google_oauth2_omniauth_authorize_path %>
user/user_cal.html.erb
<p>ログイン完了</p>
ルーティング
Rails.application.routes.draw do devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" } get 'user/cal', as: 'user_root' root to: 'welcome#index' end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/14 17:35