Added support for session checking
This commit is contained in:
parent
2f5d82d714
commit
efc36e82dd
@ -1,24 +1,24 @@
|
|||||||
|
import functools
|
||||||
import logging
|
import logging
|
||||||
|
from webob import exc
|
||||||
|
from portas.db.api import SessionRepository
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# def verify_tenant(func):
|
def verify_session(func):
|
||||||
# @functools.wraps(func)
|
@functools.wraps(func)
|
||||||
# def __inner(self, req, tenant_id, *args, **kwargs):
|
def __inner(self, request, *args, **kwargs):
|
||||||
# if hasattr(req, 'context') and tenant_id != req.context.tenant:
|
if hasattr(request, 'context') and request.context.session:
|
||||||
# LOG.info('User is not authorized to access this tenant.')
|
repo = SessionRepository()
|
||||||
# raise webob.exc.HTTPUnauthorized
|
session = repo.get(request.context.session)
|
||||||
# return func(self, req, tenant_id, *args, **kwargs)
|
if session.status != 'open':
|
||||||
# return __inner
|
LOG.info('Session is already deployed')
|
||||||
#
|
raise exc.HTTPUnauthorized
|
||||||
#
|
else:
|
||||||
# def require_admin(func):
|
LOG.info('No session is supplied')
|
||||||
# @functools.wraps(func)
|
raise exc.HTTPUnauthorized
|
||||||
# def __inner(self, req, *args, **kwargs):
|
return func(self, request, *args, **kwargs)
|
||||||
# if hasattr(req, 'context') and not req.context.is_admin:
|
return __inner
|
||||||
# LOG.info('User has no admin priviledges.')
|
|
||||||
# raise webob.exc.HTTPUnauthorized
|
|
||||||
# return func(self, req, *args, **kwargs)
|
|
||||||
# return __inner
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user