| | 33 | === Functions added to AuthS3 class === |
| | 34 | All authentication functions should be stored in the AuthS3 class in {{{modules/sahana.py}}}. |
| | 35 | |
| | 36 | {{{shn_accessible_query()}}} & {{{shn_has_permission()}}} should be moved from {{{00_utils.py}}} to here. |
| | 37 | |
| | 38 | New function: |
| | 39 | {{{ |
| | 40 | def shn_has_role(self, role): |
| | 41 | """ |
| | 42 | Check whether the currently logged-in user has a role |
| | 43 | @param role can be integer or a name |
| | 44 | """ |
| | 45 | |
| | 46 | if type(role) != int: |
| | 47 | role = deployment_settings.auth.roles[role] |
| | 48 | |
| | 49 | if role in session.s3.roles: |
| | 50 | return True |
| | 51 | else: |
| | 52 | return False |
| | 53 | }}} |