Added authenticate method in user.rb.