# coding: utf-8
class UsersController < ApplicationController
layout 'buh'
  skip_before_filter :login_required
  skip_before_filter :check_roles

  def new
    @person = Person.new
  end

  def create
    @person = Person.new(params[:person])
    if @person.save
      flash[:notice] = "Сотрудник создан!"
      redirect_to home_path
    else
      flash[:error] = @person.errors.each_full { |msg| puts msg }
      render :action => 'new'
    end
  end
  
def set_pass
  @user = Person.new
end

def update_pass
  @user = Person.find_by_nic params[:person][:nic]
  if @user.update_attributes(params[:person])
    flash[:notice] = "Пароль обновлён!"
    redirect_to home_path
  else
    flash[:error] = @user.errors.each_full { |msg| puts msg }
    render :action => 'set_pass'
  end
end



end
