Sha256: 6aa643a21cf486c3575a54578e9d30313a12951b236b5b38b67854750b7fd82f
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
<% module_namespacing do -%> class <%= class_name %>::OmniauthCallbacksController < Devise::OmniauthCallbacksController <% providers.each do |provider| -%> def <%= provider %> create end <% end -%> private def create auth_params = request.env["omniauth.auth"] provider = AuthenticationProvider.where(name: auth_params.provider).first authentication = provider.<%= class_name.downcase %>_authentications.where(uid: auth_params.uid).first if authentication sign_in_with_existing_authentication(authentication) elsif <%= class_name.downcase %>_signed_in? create_authentication_and_sign_in(auth_params, current_<%= class_name.downcase %>, provider) else create_<%= class_name.downcase %>_and_authentication_and_sign_in(auth_params, provider) end end def sign_in_with_existing_authentication(authentication) sign_in_and_redirect(:<%= class_name.downcase %>, authentication.<%= class_name.downcase %>) end def create_authentication_and_sign_in(auth_params, <%= class_name.downcase %>, provider) <%= class_name %>Authentication.create_from_omniauth(auth_params, <%= class_name.downcase %>, provider) sign_in_and_redirect(:<%= class_name.downcase %>, <%= class_name.downcase %>) end def create_<%= class_name.downcase %>_and_authentication_and_sign_in(auth_params, provider) <%= class_name.downcase %> = <%= class_name %>.create_from_omniauth(auth_params) if <%= class_name.downcase %>.valid? create_authentication_and_sign_in(auth_params, <%= class_name.downcase %>, provider) else flash[:error] = <%= class_name.downcase %>.errors.full_messages.first redirect_to new_<%= class_name.downcase %>_registration_url end end end <% end -%>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
domp-0.0.1 | lib/generators/domp/templates/omniauth_callbacks_controller.rb |