How to verify the correct user password without entering them into the system using Devise?

I program the timeclock system, where the user effectively hits his timelock by entering their username and password on a specific computer. The timeclock user will log in first. I just need to register what the user has discovered by checking that they have entered username and password correctly. How to do it in Devise ?

I do not want them to register in , just make sure that they are who they call themselves. The timeclock user is always a registered user.

+4
source share
2 answers

If you are using gem devise. Try

 User.find(1).valid_password?('password123') # returns true/false 

This code in the file: devise / lib / devise / models / database_authenticatable.rb

+4
source

Use development methods

Devise gives you two built-in methods that let you do just that:

 user = User.find_for_authentication(username: params[:username]) user.valid_password?(params[:password]) 
+1
source

All Articles