From c057590a3aaafada6d8a17a7943a04e03a9cd6c4 Mon Sep 17 00:00:00 2001 From: aceArt-GmbH <33117017+aceArt-GmbH@users.noreply.github.com> Date: Tue, 13 Dec 2022 02:18:20 +0100 Subject: [PATCH] Fix sorting admin user list by last login (#22081) (#22106) Backport of #22081 Co-authored-by: KN4CK3R --- routers/web/explore/user.go | 4 ++++ templates/admin/user/list.tmpl | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/routers/web/explore/user.go b/routers/web/explore/user.go index ea0d7d5f9d..64c84e0118 100644 --- a/routers/web/explore/user.go +++ b/routers/web/explore/user.go @@ -58,6 +58,10 @@ func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions, orderBy = "`user`.updated_unix ASC" case "reversealphabetically": orderBy = "`user`.name DESC" + case "lastlogin": + orderBy = "`user`.last_login_unix ASC" + case "reverselastlogin": + orderBy = "`user`.last_login_unix DESC" case UserSearchDefaultSortType: // "alphabetically" default: orderBy = "`user`.name ASC" diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index 963a440e29..edc58b7855 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -76,9 +76,9 @@ {{.i18n.Tr "admin.users.2fa"}} {{.i18n.Tr "admin.users.repos"}} {{.i18n.Tr "admin.users.created"}} - + {{.i18n.Tr "admin.users.last_login"}} - {{SortArrow "leastupdate" "recentupdate" $.SortType false}} + {{SortArrow "lastlogin" "reverselastlogin" $.SortType false}} {{.i18n.Tr "admin.users.edit"}}