1
0
Fork 0
forked from OpenNeo/impress
impress/app/controllers/devise/omniauth_callbacks_controller.rb
Emi Matchu 3419f8b8d1 Tweak NeoPass login success messages, to focus less on random username
Until we have more figured out about the username situation here, let's
not greet the user by the name we *generated* for them.
2024-04-01 06:00:49 -07:00

49 lines
1.6 KiB
Ruby

class Devise::OmniauthCallbacksController < ApplicationController
rescue_from AuthUser::MissingAuthInfoError, with: :missing_auth_info
rescue_from ActiveRecord::RecordInvalid, with: :validation_failed
def neopass
@auth_user = AuthUser.from_omniauth(request.env["omniauth.auth"])
if @auth_user.previously_new_record?
flash[:notice] =
"Welcome to Dress to Impress! We've set up a DTI account for you, " +
"attached to your NeoPass. Click Settings in the top right to learn " +
"more, or just go ahead and get started!"
else
flash[:notice] =
"Welcome back, #{@auth_user.name}! You are now logged in. 💖"
end
sign_in_and_redirect @auth_user, event: :authentication
end
def failure
flash[:warning] =
"Hrm, something went wrong in our connection to NeoPass, sorry! " +
"Maybe wait a moment and try again?"
redirect_to new_auth_user_session_path
end
def missing_auth_info(error)
Sentry.capture_exception error
Rails.logger.error error.full_message
flash[:warning] =
"Hrm, our connection with NeoPass didn't return the information we " +
"usually expect, sorry! If this keeps happening, please email me at " +
"matchu@openneo.net so I can help investigate!"
redirect_to new_auth_user_session_path
end
def validation_failed(error)
Sentry.capture_exception error
Rails.logger.error error.full_message
flash[:warning] =
"Hrm, the connection with NeoPass worked, but we had trouble saving " +
"your account, sorry! If this keeps happening, please email me at " +
"matchu@openneo.net so I can help investigate!"
redirect_to new_auth_user_session_path
end
end