2011-07-04 1 views

답변

0

아래와 같이 lib/authenticated_system.rblogin_from_anonymous 메서드를 생성했습니다. 이 메소드는 current_user 메소드라고도하며 아래에 나와 있습니다.

def login_from_anonymous 
    user = User.new({"new_profile_attributes"=>         
         { "country_code"=>"", "zip"=>"", "first_name"=>"Anonymous", 
         "last_name"=>"User", "affiliation_id"=>"1" 
         }, 
        "password"    => "anonymous123", 
        "password_confirmation" => "anonymous123", 
        #"invitation_token"  => "", 
        "invitation_limit"  => 0,       
        "login"     => "anonymous_#{Time.now.strftime("%m-%d-%y+%I:%M:%S%p")}", 
        "email"     => "[email protected]", 
        "current_ip"    => request.env['REMOTE_ADDR']})  
    user.send(:create_without_callbacks) 
    self.current_user = user 
    handle_remember_cookie! true # freshen cookie token (keeping date) 
    self.current_user 
end 

def current_user  
    @current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie || login_from_anonymous) unless @current_user == false 
end 
0

안심할 수있는 인증이 도움이 될 것이라고 생각하지 않습니까? 나는 당신이 그것에 대한 자신의 방법을 만들어야 할 것 같아요.

왜 IP와 사용자 에이전트를 함께 사용 하시겠습니까? IP 주소만으로도 충분합니까?

관련 문제