Mercurial > public > src > rhodecode
diff pylons_app/lib/auth.py @ 312:d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Added permission fetching for each request in AuthUser instance
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 28 Jun 2010 13:54:47 +0200 |
parents | 0e5455fda8fd |
children | d6e2817734d2 |
line wrap: on
line diff
--- a/pylons_app/lib/auth.py Sat Jun 26 18:42:13 2010 +0200 +++ b/pylons_app/lib/auth.py Mon Jun 28 13:54:47 2010 +0200 @@ -27,7 +27,7 @@ from pylons import session, url, app_globals as g from pylons.controllers.util import abort, redirect from pylons_app.model import meta -from pylons_app.model.db import User +from pylons_app.model.db import User, Repo2Perm from sqlalchemy.exc import OperationalError from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound import crypt @@ -91,7 +91,18 @@ all_perms = sa.query(Permission).all() config['pylons.app_globals'].available_permissions = [x.permission_name for x in all_perms] - +def get_user(session): + """ + Gets user from session, and wraps permissions into user + @param session: + """ + user = session.get('hg_app_user', AuthUser()) + if user.is_authenticated: + sa = meta.Session + user.permissions = sa.query(Repo2Perm)\ + .filter(Repo2Perm.user_id == user.user_id).all() + + return user #=============================================================================== # DECORATORS