19 lines
558 B
Ruby
19 lines
558 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'teamsnap'
|
|
class MainController < ApplicationController
|
|
include SessionsHelper
|
|
before_action :logged_in_user
|
|
def index
|
|
TeamSnap.init(token: @credentials['token'],
|
|
headers: { 'Authorization' => "Bearer #{@credentials['token']}" })
|
|
@teamsnap_client = TeamSnap.root_client
|
|
if session[:team_id]
|
|
redirect_to team_path(team_id: session[:team_id])
|
|
else
|
|
teams = TeamSnap::Team.search(@teamsnap_client, { user_id: @user_id })
|
|
redirect_to team_list_url
|
|
end
|
|
end
|
|
end
|