""" Disable multi-factor authentication (MFA) for the user. """ from manhattan.nav import Nav from manhattan.users import views from blueprints.users.manage.config import UserConfig # Chains disable_chains = views.mfa.disable_chains.copy() # Set the URL UserConfig.add_view_rule('/security/mfa/disable', 'mfa_disable', disable_chains) # Set the nav rules Nav.apply(UserConfig.get_endpoint('mfa_disable'), ['mfa_enabled'])
""" Regenerate the user's list of recovery codes. """ from manhattan.nav import Nav from manhattan.users import views from blueprints.users.manage.config import UserConfig # Chains regenerate_recovery_codes_chains \ = views.mfa.regenerate_recovery_codes_chains.copy() # Set URL UserConfig.add_view_rule('/security/mfa/regenerate-recovery-codes', 'mfa_regenerate_recovery_codes', regenerate_recovery_codes_chains) # Set nav rules Nav.apply(UserConfig.get_endpoint('mfa_regenerate_recovery_codes'), ['mfa_enabled'])
""" Delete a asset. """ import time from manhattan.manage.views import generic from manhattan.nav import Nav from blueprints.assets.manage.config import AssetConfig # Chains delete_chains = generic.delete.copy() @delete_chains.link def delete_document(state): # Set the asset to expire now state.asset.expires = time.time() - 1 state.asset.update('expires', 'modified') # Set URL AssetConfig.add_view_rule('/assets/delete', 'delete', delete_chains) # Set nav rules Nav.apply(AssetConfig.get_endpoint('delete'), ['not_expired'])
""" Delete a user. """ from manhattan.nav import Nav from manhattan.users import views from blueprints.users.manage.config import UserConfig # Chains delete_chains = views.delete_chains.copy() # Set the URL UserConfig.add_view_rule('/users/delete', 'delete', delete_chains) # Set the nav rules Nav.apply(UserConfig.get_endpoint('delete'), ['not_me'])
""" Download a text file containing the user's recovery codes. """ from manhattan.nav import Nav from manhattan.users import views from blueprints.users.manage.config import UserConfig # Chains download_recovery_codes_chains \ = views.mfa.download_recovery_codes_chains.copy() # Set the URL UserConfig.add_view_rule('/security/mfa/download-recovery-codes', 'mfa_download_recovery_codes', download_recovery_codes_chains) # Set nav rules Nav.apply(UserConfig.get_endpoint('mfa_download_recovery_codes'), ['mfa_enabled'])
projection={ 'created': True, 'account': { '$ref': Account, 'public_backend_settings': True, 'secure_backend_settings': True }, 'secure': True, 'name': True, 'uid': True, 'ext': True, 'type': True, 'expires': True, 'variations': { '$sub.': Variation } } ) # Set URL AssetConfig.add_view_rule( '/assets/variations/download', 'download_variation', download_chains, initial_state ) # Set nav rules Nav.apply(AssetConfig.get_endpoint('download_variation'), ['not_expired'])
# Custom overrides @list_chains.link def decorate(state): generic.view['get'].super(state) # Remove actions state.decor['actions'] = None # Breadcrumbs state.decor['breadcrumbs'] = NavItem() state.decor['breadcrumbs'].add( NavItem('Assets', AssetConfig.get_endpoint('list'))) state.decor['breadcrumbs'].add( NavItem('Asset details', AssetConfig.get_endpoint('view'), {'asset': state.asset._id})) state.decor['breadcrumbs'].add(NavItem('Variations')) # Configure the view initial_state = dict(projection={'variations': {'$sub.': Variation}}) # Set URL AssetConfig.add_view_rule('/assets/variations', 'variations', list_chains, initial_state) # Set nav rules Nav.apply(AssetConfig.get_endpoint('variations'), ['not_expired'])
# Custom overrides @view_chains.link def decorate(state): generic.view['get'].super(state) # Download state.decor['actions'].add( NavItem('Download', AssetConfig.get_endpoint('download'), view_args={'asset': state.asset._id})) # Configure the view initial_state = dict( projection={ 'account': { '$ref': Account, 'name': True, 'public_backend_settings': True, 'secure_backend_settings': True } }) # Set URL AssetConfig.add_view_rule('/assets/view', 'view', view_chains, initial_state) # Set nav rules Nav.apply(AssetConfig.get_endpoint('view'), ['not_expired'])