<commit_before>class SessionsController < ApplicationController
  def create
    user = User.from_sso(omniauth_info)
    session[:sso_data] = omniauth_info

    if user
      session[:current_user_id] = user.id

      redirect_to session.delete(:redirect_path) || prison_inbox_path
    else
      flash[:notice] = t('.cannot_sign_in')
      redirect_to root_path
    end
  end

  def destroy
    sso_signout_url = sso_link(:logout)
    session.delete(:current_user_id)
    session.delete(:sso_data)
    redirect_to sso_signout_url
  end

private

  # Set by the omni auth strategy in lib/mojsso.rb
  def omniauth_info
    request.env['omniauth.auth'].fetch('info')
  end
end<commit_msg>Redirect back to the staff guide after SSO logout<commit_after>class SessionsController < ApplicationController
  def create
    user = User.from_sso(omniauth_info)
    session[:sso_data] = omniauth_info

    if user
      session[:current_user_id] = user.id

      redirect_to session.delete(:redirect_path) || prison_inbox_path
    else
      flash[:notice] = t('.cannot_sign_in')
      redirect_to root_path
    end
  end

  def destroy
    sso_signout_url = URI.parse(sso_link(:logout))

    # Redirect to staff guide on signout rather than the (default) sso login
    sso_signout_url.query = {redirect_to: root_url}.to_query

    session.delete(:current_user_id)
    session.delete(:sso_data)
    redirect_to sso_signout_url.to_s
  end

private

  # Set by the omni auth strategy in lib/mojsso.rb
  def omniauth_info
    request.env['omniauth.auth'].fetch('info')
  end
end
{'fraction_non_alphanumeric': 0.08248081841432225, 'fraction_numerical': 0.0, 'mean_word_length': 3.68562874251497, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4923518', 'n_tokens_mistral': 537, 'n_tokens_neox': 518, 'n_words': 114}