I am working on OTP signin rails application.I have used active model otp gem for generating the otp.The gem creates otp_secret_key column to store otp. The application sends the OTP via mail to user.Then the user should enter email and correct otp to login (session should get created).I am stuck on the part of creating session.The code for session is as follows:
def create user = User.find_by(email: params[:session][:email]) otp = params[:session][:otp_code] if user.authenticate_otp(otp) session[:user_id] = user.id flash[:success] = 'Successfully logged in' redirect_to welcome_home_path else flash.now[:danger] = 'Something wrong with your login information!' end end
The parameters present in params hash after submitting the form are:
Parameters: {"utf8"=>"✓", "session"=>{"email"=>"[email protected]", "otp_code"=>"8496"}, "commit"=>"Login"}
But the on the browser it get stucks on the same page and in the terminal it shows tha No template found for SessionsController#create, rendering head :no_content
But I want to redirect it to welcome/home path if the values entered are correct.
How to do that?
P.S: I have user table with user_id,user_email and otp_secret_key column Thanks in advance
can't covert symbol to integer
– Moriarty