diff --git a/README.developer.md b/README.developer.md index e3d20a8..c88af9f 100644 --- a/README.developer.md +++ b/README.developer.md @@ -23,6 +23,16 @@ The private key is: ## Amazon +Client ID: + + amzn1.application-oa2-client.78d832919fc24456b0636762cf18efd9 + +Client Secret: + + 8c495d0940ca4100313c03e93b8b4240eef256d2fdbe672718506f29f5a20f61 + +Available login buttons: https://login.amazon.com/button-guide + ## launchpad ## Github diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index d6d5cb5..5c664f1 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,9 +1,9 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController - def passthru - raise - send(params[:provider]) if providers.include?(params[:provider]) - end + # def passthru + # raise + # send(params[:provider]) if providers.include?(params[:provider]) + # end def launchpad # You need to implement the method below in your model (e.g. app/models/user.rb) @@ -32,13 +32,26 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController end end - def failure - redirect_to root_path + def amazon + # You need to implement the method below in your model (e.g. app/models/user.rb) + @user = User.from_omniauth(request.env["omniauth.auth"]) + + if @user.persisted? + flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Amazon" + sign_in_and_redirect @user, :event => :authentication + else + # session["devise.google_data"] = request.env["omniauth.auth"].except(:extra) #Removing extra as it can overflow some session stores + redirect_to new_user_session_url, alert: @user.errors.full_messages.join("\n") + end end - private + # def failure + # redirect_to root_path + # end - def providers - ["twitter", "google_oauth2"] - end + # private + # + # def providers + # ["twitter", "google_oauth2", "launchpad", "amazon"] + # end end diff --git a/app/models/user.rb b/app/models/user.rb index 222bbaa..9547e4e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,7 +9,7 @@ class User < ApplicationRecord # :validatable, :timeoutable, # :lockable, - :omniauthable, :omniauth_providers => [:google_oauth2, :launchpad] + :omniauthable, :omniauth_providers => [:google_oauth2, :launchpad, :amazon] # :omniauthable, :omniauth_providers => [:launchpad, :google] diff --git a/app/views/devise/sessions/new.slim b/app/views/devise/sessions/new.slim index 5a6cc93..20ed454 100644 --- a/app/views/devise/sessions/new.slim +++ b/app/views/devise/sessions/new.slim @@ -36,4 +36,7 @@ / = link_to "Sign in with Launchpad", user_launchpad_omniauth_authorize_path = link_to "Sign in with Google", user_google_oauth2_omniauth_authorize_path + = link_to "Sign in with Launchpad", user_launchpad_omniauth_authorize_path + += link_to "Sign in with Amazon", user_amazon_omniauth_authorize_path diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 8f407f5..f5a4423 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -275,8 +275,11 @@ Devise.setup do |config| # config.omniauth :launchpad, 'debshots' config.omniauth :google_oauth2, '398593918966-0fpmit0pb6ptio1ndsie5dfcnqhei63l.apps.googleusercontent.com', 'uRQq_dLs1kx7l5sYIyEyPVRc', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}} + config.omniauth :launchpad, 'Debian Screenshots', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}} + config.omniauth :amazon, 'amzn1.application-oa2-client.78d832919fc24456b0636762cf18efd9', '8c495d0940ca4100313c03e93b8b4240eef256d2fdbe672718506f29f5a20f61', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}} + end # OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE