mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 00:07:02 -04:00
Add view that displays user information, including:
- name - email - phone number - services - last login - failed login attempts if any The view can be accessed from results of find_users_by_email logged_in_at added to User serialization on admin frontend as a part of this work
This commit is contained in:
@@ -855,10 +855,11 @@ class SearchTemplatesForm(StripWhitespaceForm):
|
||||
|
||||
class SearchUsersByEmailForm(StripWhitespaceForm):
|
||||
|
||||
search = SearchField('Search by name or email address',
|
||||
search = SearchField(
|
||||
'Search by name or email address',
|
||||
validators=[
|
||||
DataRequired("You need to enter full or partial e-mail address to search by.")
|
||||
]
|
||||
DataRequired("You need to enter full or partial email address to search by.")
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from flask import abort, render_template, request, url_for
|
||||
from flask import render_template, request
|
||||
from flask_login import login_required
|
||||
|
||||
from app import user_api_client
|
||||
from app.main import main
|
||||
from app.utils import user_is_platform_admin
|
||||
from app.main.forms import SearchUsersByEmailForm
|
||||
from app.utils import user_is_platform_admin
|
||||
|
||||
|
||||
@main.route("/find-users-by-email", methods=['GET', 'POST'])
|
||||
@@ -23,3 +23,14 @@ def find_users_by_email():
|
||||
form=form,
|
||||
users_found=users_found
|
||||
), status
|
||||
|
||||
|
||||
@main.route("/users/<user_id>", methods=['GET'])
|
||||
@login_required
|
||||
@user_is_platform_admin
|
||||
def user_information(user_id):
|
||||
user = user_api_client.get_user(user_id)
|
||||
return render_template(
|
||||
'views/find-users/user-information.html',
|
||||
user=user
|
||||
)
|
||||
|
||||
@@ -76,15 +76,17 @@ class HeaderNavigation(Navigation):
|
||||
'add_organisation',
|
||||
'create_email_branding',
|
||||
'email_branding',
|
||||
'find_users_by_email',
|
||||
'live_services',
|
||||
'organisations',
|
||||
'platform_admin',
|
||||
'platform_admin_list_complaints',
|
||||
'suspend_service',
|
||||
'trial_services',
|
||||
'update_email_branding',
|
||||
'user_information',
|
||||
'view_provider',
|
||||
'view_providers',
|
||||
'platform_admin_list_complaints',
|
||||
},
|
||||
'sign-in': {
|
||||
'sign_in',
|
||||
@@ -399,6 +401,7 @@ class MainNavigation(Navigation):
|
||||
'error',
|
||||
'features',
|
||||
'feedback',
|
||||
'find_users_by_email',
|
||||
'forgot_password',
|
||||
'get_example_csv',
|
||||
'get_notifications_as_json',
|
||||
@@ -472,6 +475,7 @@ class MainNavigation(Navigation):
|
||||
'two_factor_email',
|
||||
'two_factor_email_sent',
|
||||
'update_email_branding',
|
||||
'user_information',
|
||||
'user_profile',
|
||||
'user_profile_email',
|
||||
'user_profile_email_authenticate',
|
||||
@@ -567,6 +571,7 @@ class CaseworkNavigation(Navigation):
|
||||
'error',
|
||||
'features',
|
||||
'feedback',
|
||||
'find_users_by_email',
|
||||
'forgot_password',
|
||||
'get_example_csv',
|
||||
'get_notifications_as_json',
|
||||
@@ -687,6 +692,7 @@ class CaseworkNavigation(Navigation):
|
||||
'two_factor_email_sent',
|
||||
'update_email_branding',
|
||||
'usage',
|
||||
'user_information',
|
||||
'user_profile',
|
||||
'user_profile_email',
|
||||
'user_profile_email_authenticate',
|
||||
@@ -789,6 +795,7 @@ class OrgNavigation(Navigation):
|
||||
'error',
|
||||
'features',
|
||||
'feedback',
|
||||
'find_users_by_email',
|
||||
'forgot_password',
|
||||
'get_example_csv',
|
||||
'get_notifications_as_json',
|
||||
@@ -908,6 +915,7 @@ class OrgNavigation(Navigation):
|
||||
'two_factor_email_sent',
|
||||
'update_email_branding',
|
||||
'usage',
|
||||
'user_information',
|
||||
'user_profile',
|
||||
'user_profile_email',
|
||||
'user_profile_email_authenticate',
|
||||
|
||||
@@ -59,6 +59,7 @@ class User(UserMixin):
|
||||
self.failed_login_count = fields.get('failed_login_count')
|
||||
self.state = fields.get('state')
|
||||
self.max_failed_login_count = max_failed_login_count
|
||||
self.logged_in_at = fields.get('logged_in_at')
|
||||
self.platform_admin = fields.get('platform_admin')
|
||||
self.current_session_id = fields.get('current_session_id')
|
||||
self.services = fields.get('services', [])
|
||||
|
||||
@@ -2,17 +2,13 @@
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block per_page_title %}
|
||||
Find users by e-mail
|
||||
{% endblock %}
|
||||
|
||||
{% block org_page_title %}
|
||||
Find users by e-mail
|
||||
Find users by email
|
||||
{% endblock %}
|
||||
|
||||
{% block platform_admin_content %}
|
||||
|
||||
<h1 class="heading-large">
|
||||
Find users by e-mail
|
||||
Find users by email
|
||||
</h1>
|
||||
|
||||
<form
|
||||
@@ -24,7 +20,7 @@
|
||||
{{ textbox(
|
||||
form.search,
|
||||
width='1-1',
|
||||
label='Find users by e-mail, or by partial e-mail'
|
||||
label='Find users by email, or by partial email'
|
||||
) }}
|
||||
</div>
|
||||
<div class="column-one-quarter align-button-with-textbox">
|
||||
@@ -42,8 +38,8 @@
|
||||
<ul>
|
||||
{% for user in users_found %}
|
||||
<li class="browse-list-item">
|
||||
<a href="#" class="browse-list-link">{{ user.email_address }}</a>
|
||||
<p class="browse-list-sub-item">{{ user.name }}</p>
|
||||
<a href="{{url_for('.user_information', user_id=user.id)}}" class="browse-list-link">{{ user.email_address }}</a>
|
||||
<p class="browse-list-hint">{{ user.name }}</p>
|
||||
</li>
|
||||
<hr>
|
||||
{% endfor %}
|
||||
|
||||
43
app/templates/views/find-users/user-information.html
Normal file
43
app/templates/views/find-users/user-information.html
Normal file
@@ -0,0 +1,43 @@
|
||||
{% extends "views/platform-admin/_base_template.html" %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block per_page_title %}
|
||||
User information for {{ user.name }}
|
||||
{% endblock %}
|
||||
|
||||
{% block platform_admin_content %}
|
||||
<div class="grid-row bottom-gutter">
|
||||
<div class="column-whole">
|
||||
<h1 class="heading-large">
|
||||
{{ user.name }}
|
||||
</h1>
|
||||
<p>{{ user.email_address }}</p>
|
||||
<p>{{ user.mobile_number }}</p>
|
||||
<h2 class="heading-medium">Services</h2>
|
||||
<nav class="browse-list">
|
||||
<ul>
|
||||
{% for service in user.services %}
|
||||
<li class="browse-list-item">
|
||||
<p class="browse-list-sub-item">{{ service.name }}</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</nav>
|
||||
<h2 class="heading-medium">Last login</h2>
|
||||
{% if not user.logged_in_at %}
|
||||
<p>This person has never logged in</p>
|
||||
{% else %}
|
||||
<p>Last logged in
|
||||
<time class="timeago" datetime="{{ user.logged_in_at }}">
|
||||
{{ user.logged_in_at|format_delta }}
|
||||
</time>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if user.failed_login_count > 0 %}
|
||||
<p style="color:#b10e1e;">
|
||||
{{ user.failed_login_count }} failed login attempts
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user