class SessionsController

Public Instance Methods

after_login_path() click to toggle source

Redirect user to admin_universities page if user is admin or to schedule page if user is tutor or student after login.

# File app/controllers/sessions_controller.rb, line 36
def after_login_path
  unless current_user.super_admin?
    return edit_profile_path('courses_studying') unless current_user.is_registration_completed?
    session[:tutoring_session] ? profile_path(session[:tutoring_session][:tutor_id]) : (session.delete(:return_to_url) || personal_calendar_path)
  else
    admin_universities_path
  end
end
create() click to toggle source

Create new session when user login.

# File app/controllers/sessions_controller.rb, line 18
def create
  if login(params[:session][:email], params[:session][:password], params[:session][:remember_me])
    if session.delete(:init_chat)
      init_chat_with(session.delete(:user_ids))
    end
    respond_to do |format|
      format.html { redirect_to after_login_path}
      format.js { redirect_via_turbolinks_to after_login_path}
    end
  else
    respond_to do |format|
      format.html { render 'new'}
      format.js
    end
  end
end
destroy() click to toggle source

To destroy the session when user logout.

# File app/controllers/sessions_controller.rb, line 46
def destroy
  cookies.delete(:profile_question)
  logout
  redirect_to root_url, :notice => 'Bye. You have been logged out.'
end
new() click to toggle source

Intialize new session object for user.

# File app/controllers/sessions_controller.rb, line 8
def new
  if request.xhr?
    render layout: false
  else
    @testimonials = Testimonial.active
    @tutors = User.where(is_featured: true).page(params[:page]).per(params[:per_page])
  end
end