Fix session.save() for cookie sessions, add vcsserver/rc_license stubs
- Guard all session.save() calls with hasattr checks for CookieSession compatibility (CookieSession auto-saves via response callbacks) - Guard beaker-specific _set_cookie_expires and _update_cookie_out in login views - Defer ldap scope_labels to property to avoid class-level AttributeError when python-ldap is not installed - Add vcsserver stub package to allow imports without full vcsserver - Add rc_license stub for CE edition (no license management)
This commit is contained in:
parent
784a89fc9e
commit
dc3502fed0
10 changed files with 46 additions and 10 deletions
|
|
@ -73,18 +73,20 @@ def store_user_in_session(session, user_identifier, remember=False):
|
|||
Session().commit()
|
||||
|
||||
# If they want to be remembered, update the cookie
|
||||
if remember:
|
||||
if remember and hasattr(session, '_set_cookie_expires'):
|
||||
_year = datetime.datetime.now() + datetime.timedelta(seconds=60 * 60 * 24 * 365)
|
||||
session._set_cookie_expires(_year)
|
||||
|
||||
session.save()
|
||||
if hasattr(session, 'save'):
|
||||
session.save()
|
||||
|
||||
safe_cs = cs.copy()
|
||||
safe_cs["password"] = "****"
|
||||
log.info("user %s is now authenticated and stored in session, session attrs %s", user_identifier, safe_cs)
|
||||
|
||||
# dumps session attrs back to cookie
|
||||
session._update_cookie_out()
|
||||
if hasattr(session, '_update_cookie_out'):
|
||||
session._update_cookie_out()
|
||||
# we set new cookie
|
||||
headers = None
|
||||
if session.request["set_cookie"]:
|
||||
|
|
|
|||
|
|
@ -204,7 +204,8 @@ class MyAccountView(BaseAppView, DataGridAppView):
|
|||
else:
|
||||
instance = c.auth_user.get_instance()
|
||||
self.session.setdefault("rhodecode_user", {}).update({"password": md5_safe(instance.password)})
|
||||
self.session.save()
|
||||
if hasattr(self.session, 'save'):
|
||||
self.session.save()
|
||||
h.flash(_("Successfully updated password"), category="success")
|
||||
|
||||
raise HTTPFound(self.request.route_path("my_account_password"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue