0
저는 개발중인 웹 앱용 API를 구축하고 있으며 API 인증/로그인에 사용하려는 다음 코드는 인증시 false를 반환합니다. 내 API 사용자 컨트롤러에서Ruby on rails .authentication fail
나는이 : 그것은 항상 유효한 이메일 주소와 암호가 제공되는 경우에도, 거짓 @auth로 응답
def login
if params[:user]
# Find the user by email first
@user = User.where(email: params[:user][:email]).first
if [email protected]
respond_with nil
else
@auth = @user.authenticate(params[:user][:password])
if @auth
respond_with @user
else
respond_with @auth
end
end
end
end
. Mongo db에서 사용자 정보를 가져 오는 데는 아무런 문제가 없습니다.
나는 .authenticate가하는 일에 대해 명확하지 않다. 내가 본 Railscast.com 비디오에 따르면, 사용자 암호를 입력 한 암호와 비교해야합니다. 사용자에게 유효한 암호가 제공되면 @auth는 항상 false입니다.
은 railscast # 250에서 가져온 것입니까? 그렇다면 인증 기능에 전자 메일을 전달할 필요도 없습니까? –