===================
check_password_hash
===================

.. py:method:: check_password_hash(self, pwhash, password)

**domain**: server

**language**: python

**class** :doc:`Task class </refs/server/task_api>`

Description
===========

Use ``check_password_hash`` to check a password against a given salted and hashed 
password value.

The method is wrapper over Werkzeug **check_password_hash** function: 
https://werkzeug.palletsprojects.com/en/0.15.x/utils/


Example
=======


.. code-block:: py

  def on_login(task, login, password, ip, session_uuid): 
    users = task.users.copy(handlers=False)
    users.set_where(login=login)
    users.open()
    for u in users:
        if task.check_password_hash(u.password_hash.value, password):
            return {
                'user_id': users.id.value,
                'user_name': users.name.value,
                'role_id': users.role.value,
                'role_name': users.role.display_text
            }

See also
========

:doc:`generate_password_hash <m_generate_password_hash>`