Forked from dhh/user_authentications_controller.rb
Created
September 26, 2020 17:34
-
-
Save liroyleshed/5415651a5f37d7e73573fb2440d4af4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserAuthenticationsController < AuthenticatedController | |
def create | |
if authenticate | |
enroll_promotions | |
redirect_to return_path | |
else | |
redirect_to back_path, error: authentication_error_message | |
end | |
end | |
private | |
def authenticate | |
if user_authentication.authenticate!(sso_session).success? | |
self.current_token = user_authentication.authenticated_user_token | |
end | |
end | |
def enroll_promotions | |
if user_authentication.promo_applicable? | |
user_authentication.enroll! promo_id | |
flash[:success] = I18n.t("promotions.confirmation_message") | |
end | |
end | |
def authentication_error_message | |
I18n.t("user_authentication.not_allowed") if user_authentication.not_allowed? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment