Skip to content

Commit

Permalink
perf: do not validate user on session resume (frappe#29074)
Browse files Browse the repository at this point in the history
* fix: Consume sid from arguments

* perf: do not validate user on resume

Errr, why would we ever need to validate if user with active session is
"disabled"?

When active user is disabled, their sessions are wiped from cache and DB.
  • Loading branch information
ankush authored Jan 7, 2025
1 parent 77c9c9e commit 59309f8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frappe/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ class Session:
__slots__ = ("_update_in_cache", "data", "full_name", "sid", "time_diff", "user", "user_type")

def __init__(self, user, resume=False, full_name=None, user_type=None):
self.sid = cstr(frappe.form_dict.get("sid") or unquote(frappe.request.cookies.get("sid", "Guest")))
self.sid = cstr(
frappe.form_dict.pop("sid", None) or unquote(frappe.request.cookies.get("sid", "Guest"))
)
self.user = user
self.user_type = user_type
self.full_name = full_name
Expand Down Expand Up @@ -301,7 +303,6 @@ def resume(self):
if data:
self.data.update({"data": data, "user": data.user, "sid": self.sid})
self.user = data.user
self.validate_user()
validate_ip_address(self.user)
else:
self.start_as_guest()
Expand Down

0 comments on commit 59309f8

Please sign in to comment.