BCrypt Invalid Hash: Can't create an admin user

时间:2015-08-14 22:52:16

标签: ruby-on-rails postgresql passwords admin bcrypt

I have been trying to create an admin account for my app but when I log in as 'admin', I get that BCrypt invalid hash error. It does it for every user I create in my seed file. When users are created via signup form from my app it works. I have took every step to get it working and it's just not happening. I have hit a brick wall with this issue. I need someone to point me into the right direction.

Seed File

Player.create({user_name:'caddyshack3', score: 0, password_digest:'corinacorina' })
Player.create({user_name:'maryjane9', score: 0, password_digest: 'nicety'})
Player.create({user_name:'admin', score: 0, password_digest:'9905', role:'admin'})

Player Model

class Player < ActiveRecord::Base
has_secure_password

def admin?
    self.admin == 'admin'
end

end

Application Controller

  class ApplicationController < ActionController::Base

  protect_from_forgery with: :null_session

  helper_method :current_player

  def current_player
  @current_player ||= Player.find(session[:player_id]) if  session[:player_id]
  end

  def require_player
redirect_to '/login' unless current_player
  end

def require_admin
end
end

0 个答案:

没有答案