Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344class GoogleUsersController < ApplicationController include Authenticatable
def in auth = request.env['omniauth.auth'] google_user = GoogleUser.from_auth(auth, current_user) if google_user.errors.any? redirect_to redirect_path, alert: "Couldn't link with Google: #{google_user.errors.full_messages.to_sentence} :(" return end
if request.env['omniauth.origin'] == settings_url redirect_to settings_path, notice: 'Google account linked!' return end
sign_in(google_user.user) redirect_to redirect_path, notice: "'Hoy!! o/ Signed in as #{current_user}." end
def unlink current_user.google.try(:destroy) redirect_to settings_path, notice: 'Google account unlinked! 🙅🔗' end
private
def sign_in(user) create_auth_session(user) auth_session.persist! end
def redirect_path if request.env['omniauth.origin'] @originURI = URI.parse(request.env['omniauth.origin']) if @originURI.path == signin_path && @originURI.query @originURI.path = oauth_authorization_path return @originURI.to_s end end request.env['omniauth.origin'] || cookies.delete('return_to') || root_path endend