| Conditions | 4 |
| Total Lines | 16 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import typing |
||
| 13 | def check_credentials(username, password, request) -> typing.Optional[dict]: |
||
| 14 | permissions = None |
||
| 15 | app_config = request.registry.settings['CFG'] |
||
| 16 | uapi = UserApi(None, session=request.dbsession, config=app_config) |
||
| 17 | try: |
||
| 18 | user = uapi.get_one_by_email(username) |
||
| 19 | if user.validate_password(password): |
||
| 20 | permissions = [] |
||
| 21 | for group in user.groups: |
||
| 22 | permissions.append(group.group_name) |
||
| 23 | # TODO - G.M - 06-04-2018 - Add workspace specific permission ? |
||
| 24 | # TODO - G.M - 06-04-2018 - Better catch for exception of bad password, bad |
||
| 25 | # user |
||
| 26 | except: |
||
| 27 | pass |
||
| 28 | return permissions |
||
| 29 | |||
| 38 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.