0
我正在使用名爲stripe_connect的gem,它是Stripe的Oauth2解決方案。現在目前這個代碼工作正常,它是半重複性的,當涉及到將用戶控制器邏輯移動到模型中
request.env['omniauth.auth']
但旁邊我認爲它看起來不錯。不過,我希望將此從控制器中移出並放入模型中。但是,我不確定如何進行轉換。任何人都可以得到幫助嗎?
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
before_action :authenticate_user!
def stripe_connect
@user = current_user
if @user.update_attributes(
provider: request.env['omniauth.auth'].provider,
uid: request.env['omniauth.auth'].uid,
access_code: request.env['omniauth.auth'].credentials.token,
publishable_key: request.env['omniauth.auth'].info.stripe_publishable_key
)
redirect_to rooms_path
set_flash_message(:notice, :success, kind: 'Stripe') if is_navigational_format?
else
session['devise.stripe_connect_data'] = request.env['omniauth.auth']
redirect_to new_user_registration_url
end
end
end