=========
user_info
=========

.. js:attribute:: user_info

**domain**: client 

**language**: javascript

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

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

Use ``user_info`` attribute to get user information when project 
:doc:`Safe mode parameter </admin/project/parameters>`
is set. 

``user_info`` is an object that has the following attributes:

* ``user_id`` - the user id
* ``user_name`` - the user name
* ``role_id`` - user role id
* ``role_name`` - the role assigned to the user
* ``admin`` - if true the user can work in Administrator

If safe mode is false the ``user_info`` attribute is an empty
object.

Example
=======

.. code-block:: js

    function on_page_loaded(task) {
        $("#title").html('Jam.py demo application');
        if (task.safe_mode) {
            $("#user-info").text(task.user_info.role_name + ' ' + task.user_info.user_name);
            $('#log-out')
            .show()
            .click(function(e) {
                e.preventDefault();  
                task.logout();
            });
        }
        // some initalization code
    }

See also
========

:doc:`load <m_load>`

:doc:`login <m_login>`

:doc:`logout <m_logout>`

:doc:`Users </admin/users>`

:doc:`Roles </admin/roles>`
