"활성화"되기 전에 또는 이메일/비밀번호로 로그인하기 전에 사용자가 활성화 링크를 클릭하기를 원합니다.레일 - 사용자 가입시 이메일 활성화
나는 보석을 사용하지 않고 있으며 그렇게하고 싶습니다. 내 문제는 사용자가 등록한 후에 활성화 코드를 클릭하지 않고 로그인 할 수 있다는 것입니다. 나는 confirm_token 라인과 확인 된 라인을 모델에 가지고있다.
사용자 컨트롤러 :
def confirmed!
self.confirmed = true
self.confirmation_token = nil
save(false)
end
난 아무것도 실종 :
사용자 모델
def create
@user = User.new(params[:user])
if @user.save
render "root_path"
else
render "new"
end
end
def confirmed
user = User.find(:first, :conditions => {:confirmation_token => params[:confirmation_token]})
if (!params[:confirmation_token].blank?) && user && !user.confirmed?
user.confirmed!
self.current_user = user
flash[:notice] = "Thank you. You account is now activated."
redirect_to account_preference_path(current_user)
else
flash[:notice] = "Sorry we don't have your email in our database."
redirect_to root_path
end
끝? 감사!
나는 devise, auth-logic 등의 보석이 있다는 것을 알고 있지만, 처음부터 그것을 쓰는 법을 배우고 싶다. 감사.
편집 : 당신은 적어도 프로세스를 안내, 올바르게 레일을 코딩을위한 더 나은 느낌을 얻을 수 있습니다 몇 가지 튜토리얼을 검색 할 수 있습니다
세션 컨트롤러
def create
user = User.authenticate(params[:email], params[:password])
if user && user.confirmed == true
cookies.permanent.signed[:remember_token]
redirect_to account_path(user.id), :notice => "Welcome, #{user.first_name}"
else
flash.now.alert = "Invalid email or password."
render "new"
end
end
무엇이 오류입니까? – emrahbasman
사용자는 가입하고 전자 메일 주소를 확인하기 위해 활성화 링크를 클릭하지 않고 로그인하여 사이트 사용을 시작할 수 있습니다. – noob
사용자가 로그인 할 때 새 세션을 만드는 데 사용되는 코드를 게시하십시오. – drummondj