Commit graph

244 commits

Author SHA1 Message Date
Ankush Menat
bdab7e30f8
fix: Remember session creation (#33082) 2025-06-25 05:45:57 +00:00
Sagar Vora
4f6e19eec4
perf: use chain flag (#33007) 2025-06-19 11:32:25 +00:00
Sagar Vora
b3e1eda4c8
feat: global frappe.in_test flag (#32960)
* feat: global `frappe.in_test` flag

* feat: helper utility to toggle `frappe.in_test`

* fix: use `toggle_test_mode` util

* fix: use `frappe.in_test`

* chore: add comment explaining global `in_test`

* chore: ignore commit replacing flag usage

* test: temporarily disable `frappe.in_test`

this worked earlier because flag was set in werkzeug.local which was separate for API test client

* test: add comment explaining change
2025-06-17 19:19:31 +05:30
Ankush Menat
49f582ae57 perf: Use lazy doc in a lot more places 2025-06-11 09:55:45 +05:30
rohitwaghchaure
5c6b2b5bec
refactor: track completed app setup wizards and re-run the setup wizard upon new app installation. (#32640) 2025-06-03 12:36:22 +05:30
Akhil Narang
a9c1c49fff
refactor: use an alternate key for handling expiry
This allows for less changes to update() + allows impersonated sessions to not end later

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 18:27:44 +05:30
Akhil Narang
15065a93e3
refactor: don't use impersonate directly, use similar logic
This will allow impersonating as well

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 17:20:12 +05:30
Akhil Narang
1dc767f671
feat(browse): allow passing a user for impersonated_by
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 17:20:12 +05:30
Akhil Narang
332e22f00b
refactor: fix typo in impersonated
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 17:20:12 +05:30
Akhil Narang
a121b90d7f
feat: allow created a session for a fixed duration via bench browse
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-01-24 17:20:12 +05:30
Ankush Menat
e4a2b8db38
refactor: trim init.py (#29866)
* refactor: Trim `__init__.py`

We strayed from the goal here: https://github.com/frappe/frappe/pull/29181

So making up for it.

* chore!: Delete unused get_version

Not used anywhere

* refactor: move few more functions to relevant place

* asd
2025-01-20 13:05:02 +00:00
Ankush Menat
bef7393753
fix: Update sessions in cache after a miss (#29217)
Err how was this missed? After starting fresh session for first 19
minutes it doesn't seem to go to cache.
2025-01-17 08:54:35 +00:00
Ankush Menat
110e6225fc
perf: speedup sessions code (#29076)
* refactor: simplify user IP validation code

The comment suggests this way of doing it has some perf benefit, it does not.

Just fetch the entire cached doc.

* perf: remove duplicate language resolution

WHY???

* perf: avoid fetching system settings for ip-validated users

get_system_settings is client-cached

* perf: perform easier checks first

No need to fetch system settings if IP address is already matching.
2025-01-17 13:53:49 +05:30
Ankush Menat
daa52b8802
build!: Drop maxmind IP database (#29213)
1. It's severly outdated and free version isn't that accurate to begin
   with.
2. I replaced country detection using timezone a long time ago: c8ec528aa7/frappe/desk/page/setup_wizard/setup_wizard.js (L664-L676)

This is good enough for setup wizard for most popular countries. Use
IP-API if you need better guarantees (we have a license).
2025-01-17 12:03:09 +05:30
Ankush Menat
129212a916 perf: cache unseen notes 2025-01-14 19:43:22 +05:30
Ankush Menat
8682014259 perf: use client cached navbar 2025-01-14 18:49:19 +05:30
Ankush Menat
f963758a1d perf: Avoid duplicate queries 2025-01-14 18:48:28 +05:30
Ankush Menat
374bba5979 perf: use client cache for metadata version 2025-01-14 13:28:42 +05:30
Ankush Menat
59309f8164
perf: do not validate user on session resume (#29074)
* 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.
2025-01-07 12:52:23 +00:00
Ankush Menat
60a3c41c7a
perf: Avoid storing redundant information - last session update (#28922)
Session contains the same exact information, so why do we need this?
2024-12-26 12:38:14 +00:00
Ankush Menat
03036bfc91 perf: Use system settings for fetching expiry
It's just copy of the same data. IMO sys settings is always the "true"
source of truth.
2024-12-26 11:27:27 +05:30
Akhil Narang
84ef6ec677
refactor: fixup with ruff 0.8.1
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-04 13:18:04 +05:30
Shariq Ansari
bfb9d0beb8 fix: load apps_data in boot for desk 2024-09-05 19:20:52 +05:30
Akhil Narang
cd67eba32d
fix(sessions): pass force parameter to get_sessions_to_clear()
Not sure why this didn't get committed with the original PR: #27542

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-09-02 17:52:47 +05:30
Shariq Ansari
9133f2a9c5 fix: added apps data in boot 2024-08-30 15:42:58 +05:30
Akhil Narang
5570aa71be
fix(sessions): logout properly when user requests logout on password change
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-08-27 17:58:20 +05:30
Shariq Ansari
3f5d6d2c7f feat: added default app selector in user doctype 2024-08-08 19:54:02 +05:30
Shariq Ansari
67eb28d836 fix: redirect to apps if multiple apps installed or redirect to apps portal 2024-08-08 18:29:16 +05:30
Ankush Menat
a234e79790 refactor: misc changes
- Move sys setting check to server side
- tomli import handling
2024-05-04 15:08:34 +05:30
Ankush Menat
7fe9cc4f09
perf: Don't update session in cache after every request (#26308)
It's just reading and writing same information except last_update inside
data which is never read back from this.
2024-05-04 06:10:38 +00:00
Rutwik Hiwalkar
a73e65581d
fix: disabled user login from login via link feature (#26134)
* fix(ui): button color for login via link template

- blue > black

* fix: restrict login via link for disabled users

* fix: validate user on session.resume
2024-04-24 15:49:17 +05:30
Ankush Menat
bef9bdc5ee
fix: log out reliability (#25865)
* fix: Avoid possible cache eviction issue

Clear cache after removing data from DB, so a concurrent request can't put stale data in cache.

* fix: explicitly login as guest after logging out

Avoids problem with some other code potentially re-adding current
session in cache or DB.

* test: avoid hard coded admin pw

* test: reset user after running tests

* fix: only login as guest if in request

Background jobs, some other user disabling someone else etc
2024-04-09 18:56:52 +05:30
Gursheen Anand
2c0498cbdd fix: use boot to store announcement 2024-03-29 16:24:41 +05:30
Ankush Menat
7a854efc03
refactor: Use JSON for session data (#25207)
JSON is proper format compared to using safe_eval which is a hack to convert
string repr of dict object back into python object.
2024-03-04 06:47:48 +00:00
Ankush Menat
24499d93f8 fix: notify user that they were impersonated 2024-02-24 18:31:10 +05:30
Ankush Menat
be47ee0e31 fix: track all impersonated changes 2024-02-24 18:25:09 +05:30
Ankush Menat
c58ac809ac fix: Flag impersonated sessions 2024-02-24 18:25:09 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
70a6a8334f
fix: set same cookie expiry as client side (#24560) 2024-01-29 05:52:40 +00:00
Ankush Menat
484049c5ae
fix: simultenous sessions ux (#24387)
* fix: set 2 as simultaneous_sessions by default

* fix: Correct offset for simultaneous_sessions

* refactor: use freeze_time instead of patching

* chore: misleading docstring

* test: set lower simultaneous_sessions for test
2024-01-16 13:36:05 +00:00
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
Ankush Menat
ad79c9d180 chore: remove broken call to geoip
This has never worked afaik
2023-07-01 20:07:05 +05:30
Ankush Menat
0e1236b6be refactor: Simplify expiry queries.
Dont rely on mysql dateutils, simply compare dates with a cutoff.
2023-06-28 18:05:12 +05:30
Ankush Menat
d353662b53 fix: Session insert using system time
NOW() is server time not system time.
2023-06-28 17:47:22 +05:30
Ankush Menat
60efb7c2ff fix: incorrect session expiry datediff
Datediff doesn't work like this in MYSQL, mysql just treats the
timestamp as flat timestamp.
2023-06-28 17:47:22 +05:30
Ankush Menat
7c4009fde9 refactor: use QB 2023-06-28 17:47:22 +05:30
Ankush Menat
564b960678 fix: correct last update value
`NOW()` evalautes to server's time we should use system time instead.
2023-06-28 17:47:22 +05:30
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Sagar Vora
4ea39d1a68
chore!: drop device support from session (#18729)
* chore!: drop device support from session

* chore: remove `session_expiry_mobile` field

* fix: remove extra `%s`
2022-12-05 16:37:32 +05:30
Ankush Menat
87092ec0b3 fix: don't attempt to delete session during read only session 2022-09-10 12:45:25 +05:30