문제

attr_accessible :email, :password, :password_confirmation

If not, can you please give example of method which prevents 'undefined' error when attr_accessible is removed.

도움이 되었습니까?

해결책

It is safe. Attr_accessible is only dangerous for attributes that control your application logic. For example, if you have a flag that says "yes I've checked this user is an admin", and it can be set by the user instead, because it's attr_accessible, then it's a vulnerability.

Since the password is a piece of information that is provided by the user anyway, making it settable by the same user does not change anything.

다른 팁

If you are security paranoid, you could do this is defining the method password:

def password
  self.password
end

this way the password can't be set by hand.

But you shouldn’t worry about it because many login gems like devise needs password in attr_accessible.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top