#encoding: utf-8

require 'digest/md5'

class LoginController < ApplicationController

  def index
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @users }
    end
  end

  def login
    session[:user] = User.authenticate(params[:loginname],params[:password])
    if session[:user]
      #session[:nojs] = (params[:nojs]=='on')
      session[:reporting_period] = params[:date][:reporting_period]
      redirect_to :controller => params[:goal].blank? ? 'start' : params[:goal]
    else
      flash[:notice] = "<b style=\"color:red\">Benutzername oder Passwort nicht korrekt</b>"
      redirect_to :controller => :login, :action => :index
    end      
  end
  
  def logout
    tmp = flash[:notice]
    destroy_big_session
    reset_session
    flash[:notice] = tmp.nil? ? "Sie wurden erfolgreich ausgeloggt" : tmp
    redirect_to :controller => :login, :action => :index
  end
  
  def impressum
    
  end
  
 end
