module DoubleAuthEngine::UsersControllerMixin::InstanceMethods

Public Instance Methods

create() click to toggle source
# File lib/double_auth_engine/controllers/users_controller_mixin.rb, line 30
def create
  @user = User.new(params[:user])
  if @user.save
    flash[:notice] = 'User successfully created'
    respond_with(@user)
  else
    render :action => 'new', :layout => false
  end
end
destroy() click to toggle source
# File lib/double_auth_engine/controllers/users_controller_mixin.rb, line 55
def destroy
  @user = User.find(params[:id])
  @user.destroy
  respond_to do |format|
    format.html { redirect_to(users_url) }
    format.xml { head :ok }
  end
end
edit() click to toggle source
# File lib/double_auth_engine/controllers/users_controller_mixin.rb, line 40
def edit
  @user = User.find(params[:id])
  respond_with(@user)
end
index() click to toggle source
# File lib/double_auth_engine/controllers/users_controller_mixin.rb, line 13
def index
  @users = User.all
  respond_with(@users)
end
new() click to toggle source
# File lib/double_auth_engine/controllers/users_controller_mixin.rb, line 23
def new
  @user = User.new
  respond_with @user do |format|
    format.html { render :layout => false }
  end
end
show() click to toggle source
# File lib/double_auth_engine/controllers/users_controller_mixin.rb, line 18
def show
  @user = User.find(params[:id])
  respond_with @user
end
update() click to toggle source
# File lib/double_auth_engine/controllers/users_controller_mixin.rb, line 45
def update
  @user = User.find(params[:id])
  if @user.update_attributes(params[:user])
    flash[:notice] = 'User successfully updated'
    respond_with(@user)
  else
    render :action => 'edit'
  end
end
update_password() click to toggle source
# File lib/double_auth_engine/controllers/users_controller_mixin.rb, line 64
def update_password
  @user = User.find(params[:id])
  if @user.valid_password? params[:current_password]
    @user.password              = params[:password]
    @user.password_confirmation = params[:password_confirmation]
    if @user.save
      flash[:notice] = "Your password has been updated"
      redirect_to user_path(@user)
    else
      flash[:error] = @user.errors.full_messages.first
      render :action => "change_password"
    end
  else
    flash[:error] = "Your Current Password Does not Match"
    render :action => "change_password"
  end
end