Diff of /qiita_db/handlers/user.py [000000] .. [879b32]

Switch to unified view

a b/qiita_db/handlers/user.py
1
# -----------------------------------------------------------------------------
2
# Copyright (c) 2014--, The Qiita Development Team.
3
#
4
# Distributed under the terms of the BSD 3-clause License.
5
#
6
# The full license is in the file LICENSE, distributed with this software.
7
# -----------------------------------------------------------------------------
8
9
import qiita_db as qdb
10
from .oauth2 import OauthBaseHandler, authenticate_oauth
11
from .util import _get_instance
12
13
14
class UserInfoDBHandler(OauthBaseHandler):
15
    @authenticate_oauth
16
    def get(self, email):
17
        """Retrieves the User information
18
19
        Parameters
20
        ----------
21
        email: str
22
            The email of the user whose information is being retrieved
23
24
        Returns
25
        -------
26
        dict
27
            The user information as a dict
28
        """
29
        with qdb.sql_connection.TRN:
30
            user = _get_instance(qdb.user.User, email,
31
                                 'Error instantiating user')
32
            response = {'data': {'email': email, 'level': user.level,
33
                                 'password': user.password,
34
                                 'name': user.info['name']}}
35
36
            self.write(response)
37
38
39
class UsersListDBHandler(OauthBaseHandler):
40
    @authenticate_oauth
41
    def get(self):
42
        """Retrieves the Users basic information
43
44
        Returns
45
        -------
46
        list of dict
47
            The user information as a dict
48
        """
49
        with qdb.sql_connection.TRN:
50
            response = {'data': [dict(d) for d in qdb.user.User.iter()]}
51
52
            self.write(response)