Class: Pairer::SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pairer/sessions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#render_404, #robots, #signed_in?

Instance Method Details

#sign_inObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/pairer/sessions_controller.rb', line 6

def 
  if request.method == "GET"
    if signed_in?
      redirect_to boards_path
    end

  elsif request.method == "POST"
    if Pairer.config.allowed_org_ids.include?(params[:org_id]&.downcase)
      session[:pairer_current_org_id] = params[:org_id].downcase
      session[:pairer_user_id] = "#{session[:pairer_current_org_id]}_#{SecureRandom.uuid}"
      redirect_to boards_path
    end
  end
end

#sign_outObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/pairer/sessions_controller.rb', line 21

def sign_out
  if !signed_in?
    redirect_to action: :sign_in
  else
    session.delete(:pairer_current_org_id)
    session.delete(:pairer_current_board_id)
    session.delete(:pairer_user_id)
    flash.notice = "Signed out"
    redirect_to 
  end
end