Sha256: 2a09edb6b34e611c46ab9880aa1a1e3aa3fde0b84962cfb3b0f3ce7eb7da039b

Contents?: true

Size: 1.43 KB

Versions: 10

Compression:

Stored size: 1.43 KB

Contents

# encoding: UTF-8

# Copyright 2011 innoQ Deutschland GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

class UserSessionsController < ApplicationController

  skip_before_filter :require_user, :only => [:new, :create]

  def new
    authorize! :create, UserSession

    @user_session = UserSession.new
  end

  def create
    authorize! :create, UserSession

    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      @current_ability = nil
      flash[:success] = I18n.t("txt.controllers.user_sessions.login_success")
      redirect_to params[:back_to].presence || (can?(:use, :dashboard) ? dashboard_path : root_path)
    else
      flash[:error] = I18n.t("txt.views.user_sessions.error")
      render :action => :new
    end
  end

  def destroy
    authorize! :destroy, UserSession

    current_user_session.destroy
    flash[:success] = I18n.t("txt.controllers.user_sessions.logout_success")
    redirect_to root_path
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
iqvoc-4.0.9 app/controllers/user_sessions_controller.rb
iqvoc-4.0.8 app/controllers/user_sessions_controller.rb
iqvoc-4.0.7 app/controllers/user_sessions_controller.rb
iqvoc-4.0.6 app/controllers/user_sessions_controller.rb
iqvoc-4.0.5 app/controllers/user_sessions_controller.rb
iqvoc-4.0.4 app/controllers/user_sessions_controller.rb
iqvoc-4.0.3 app/controllers/user_sessions_controller.rb
iqvoc-4.0.2 app/controllers/user_sessions_controller.rb
iqvoc-4.0.1 app/controllers/user_sessions_controller.rb
iqvoc-4.0.0 app/controllers/user_sessions_controller.rb