Commit graph

214 commits

Author SHA1 Message Date
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
Ankush Menat
1ec03dacff feat(UX): Disable write actions in read-only Desk
I won't be covering each and every aspect of desk that shouldn't work in
read only mode. This just handles major interactions and assumes that
user will get a hint about why other things aren't working.

Changes:
- Add read only badge on navbar.
- Disable forms
- Disable new doc creation
2022-09-09 17:34:46 +05:30
Ankush Menat
5922c0ea35 fix: dont renew session during read only mode 2022-09-08 18:22:08 +05:30
hrwx
b01929405d refactor: translatable doctypes 2022-08-05 21:38:10 +01:00
Ankush Menat
1f9a6b010a
perf: add __slots__ to most used classes (#17421)
Added slots for these classes:

- Session - Created on EACH request
- LoginManager - Created on each request
- Monitor - Created on each request if monitor is enabled (usually in
  prod setup)
2022-07-07 11:15:50 +05:30
Gavin D'souza
3871fe6cd0 perf: App Page
Reduced time taken for get_context to execute from 0.035s to 0.02s (75%
reduction)
2022-06-13 18:39:56 +05:30
Himanshu
70409a3c7b
fix: set translated text to link field (#15451)
- Fixes [Issue/15324](https://github.com/frappe/frappe/issues/15324)
- When selecting a value for Link Field, the English text was set as link field value.
- This PR aims to fix it by setting the translated text as link field value on selection.

Todo:

- [x] Show translated text in the select dropdown
- [x] Set translated value to Link field on select
- [x] Show original value when link field is in focus
- [x] Add option to toggle this behaviour

### Behaviour

- Link field loses focus: show the translated name.
- Link field is focused
    - If old value is present
        - If options **are** one of [Role, DocType]: show the translated name
        - Else: show the name (untranslated) to enable search in untranslated values
    - Else: show what the user typed (untranslated) to enable search in untranslated values
- Value is selected: link field loses focus

## Demo

### Link to UOM in a custom Item DocType

The UOM names are in english, so the search needs to happen in english. When possible, the translation is displayed.

#### Before

https://user-images.githubusercontent.com/14891507/156415248-e5e80d05-53dc-4ca8-89c7-998986ff6e99.mov

#### After

https://user-images.githubusercontent.com/14891507/156410386-a874430c-f340-43ed-9c3a-92e8d4d50fc9.mov

### Link to DocType in Customize Form

The DocType names get translated before being searched. This is a preexisting hack in the framework for DocType and Role. In this case, we can search in the translations.

#### Before

https://user-images.githubusercontent.com/14891507/156414648-8e505f8c-9dee-4358-8182-3b358c28bb62.mov

#### After

https://user-images.githubusercontent.com/14891507/156411881-c4ca22e1-1397-4e13-9768-5e16b72f8d6d.mov

https://docs.erpnext.com/docs/v13/user/manual/en/customize-erpnext/customize-form/edit?wiki_page_patch=fdafee2715
2022-05-16 13:21:42 +00:00
phot0n
33b49b4d46 refactor(minor): remove is_first_startup from System Settings 2022-05-04 10:43:59 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Abhishek Saxena
5c8856d66e
refactor: db.sql calls to frappe.qb (#16107)
# Changes

- Introduces `subqry` class to use in where clause when there is a non-column condition. eg.
> .where(subqry(no_of_roles) == 0)
- Convert SQL queries to frappe.qb 

# Testing

Functions with query refactors
- frappe.boot.get_user_pages_or_reports() -> Same output of `get_bootinfo()` as develop
- frappe.boot.get_unseen_notes() -> Forms the same query as develop 
```sql
SELECT `name`,`title`,`content`,`notify_on_every_login`
FROM `tabNote` WHERE `notify_on_every_login`=1
AND `expire_notification_on`>'2022-03-30 01:10:53.393874'
AND (SELECT `nsb`.`user` FROM `tabNote Seen By` `nsb` WHERE `nsb`.`parent`=`tabNote`.`name`) NOT IN ('Administrator')
```
- frappe.installer._delete_doctypes() -> installed and uninsalled a dummy app to drop tables

### Not tested
- frappe.make_property_setter()
- frappe.realtime.get_pending_tasks_for_doc() [whitelist method]
- frappe.sessions.Session.start()
- frappe.twofactor.cache_2fa_data()
2022-04-12 05:07:25 +00:00
barredterra
b1383df15a refactor: use is None instead of == None 2022-01-17 10:37:51 +01:00
Suraj Shetty
b6cb0fc1e7 fix: Pass SQL string of lastupdate instead of normal string
- Normal string of pypika field has additional quotes
which creates a invalid query
- `get_sql` returns column name without additional quotes
2022-01-17 10:01:29 +05:30
Aradhya
1ff3a0d517 fix: fixed sider issues 2021-12-30 19:29:02 +05:30
Aradhya
a109034ea5 fix: frappe.db.escape in query generated by frappe.qb 2021-12-30 19:15:11 +05:30
Aradhya
08d94d991f refactor: changed query in sessions 2021-11-23 15:49:16 +05:30
Aradhya
59f54aa60c refactor: changed default_ordering to keep_default_ordering 2021-11-23 15:26:15 +05:30
Aradhya
50db6d5dd4 refactor: refactored query in sessions 2021-11-23 14:47:03 +05:30
Aradhya
9ccf467acb fix: fixed no order arg in converted queries 2021-11-23 13:30:42 +05:30
Aradhya
d37aa55607 fix: fixed merged conflicts 2021-11-18 18:13:10 +05:30
Suraj Shetty
c422a72875 Merge branch 'develop' of https://github.com/frappe/frappe into sgtpepper9907-develop 2021-11-17 11:10:57 +05:30
Aradhya-Tripathi
09e7af70ab refactor: converted raw queries 2021-11-16 15:12:58 +05:30
Faris Ansari
179960d67f
Merge pull request #14134 from netchampfaris/print-format-builder-beta
feat: New Print Format Builder
2021-10-25 12:12:08 +05:30
mergify[bot]
8cbbda7ab7
Merge pull request #14441 from Aradhya-Tripathi/query-conversion
refactor: replacing raw SQL queries with frappe ORM
2021-10-22 09:00:42 +00:00
Aradhya-Tripathi
0410a88aea refactor: replaced sql_list 2021-10-22 13:31:36 +05:30
Aradhya-Tripathi
012edfe090 refactor: made style changes & fixed query conversions 2021-10-22 01:15:46 +05:30
Faris Ansari
5345d4ce7b Merge branch 'develop' of https://github.com/frappe/frappe into print-format-builder-beta 2021-10-20 18:40:18 +05:30
Sagar Vora
c560d67a57 fix: remove/update older whitelist calls 2021-10-18 16:47:11 +05:30
Aradhya-Tripathi
4ed10de918 fix: fixed sider issues 2021-10-14 23:35:52 +05:30
Aradhya-Tripathi
f5a5f97593 refactor: converted quries in sessions.py 2021-10-14 14:32:55 +05:30
Aradhya-Tripathi
7315076038 refactor: converted queries 2021-10-13 14:06:34 +05:30
Faris Ansari
f58254db78 fix: poor man's hot reload 2021-09-06 16:57:14 +05:30