Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disabled user login from login via link feature (backport #26134) #26140

Merged
merged 3 commits into from May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions frappe/sessions.py
Expand Up @@ -223,8 +223,16 @@ def __init__(self, user, resume=False, full_name=None, user_type=None):

else:
if self.user:
self.validate_user()
self.start()

def validate_user(self):
if not frappe.get_cached_value("User", self.user, "enabled"):
frappe.throw(
_("User {0} is disabled. Please contact your System Manager.").format(self.user),
frappe.ValidationError,
)

def start(self):
"""start a new session"""
# generate sid
Expand Down Expand Up @@ -295,6 +303,7 @@ 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)
self.device = data.device
else:
Expand Down
10 changes: 4 additions & 6 deletions frappe/templates/emails/login_with_email_link.html
Expand Up @@ -23,11 +23,9 @@
</tr>
<tr>
<td align="center">
<div class="btn btn-primary" style="margin-top: 30px;">
<a href="{{ link or '#'}}" style="color: #fff; text-decoration: none;">
{{ _('Log In To {0}').format(app_name) }}
</a>
</div>
<a href="{{ link or '#'}}" class="btn btn-primary" style="background-color: #171717; text-decoration: none; margin-top: 30px;">
{{ _('Log In To {0}').format(app_name) }}
</a>
</td>
</tr>
</tbody>
Expand All @@ -38,4 +36,4 @@
<div class="body-content">
{{ table(table(body(), 'email-body'), 'email-container') }}
</div>
</div>
</div>
1 change: 0 additions & 1 deletion frappe/www/login.py
Expand Up @@ -166,7 +166,6 @@ def login_via_key(key: str):

if email:
frappe.cache().delete_value(cache_key)

frappe.local.login_manager.login_as(email)

redirect_post_login(
Expand Down