Skip to content

Commit 352a50d

Browse files
authored
Fix sorting admin user list by last login (#22081)
Admin User Account list sort `updated_unix` is not the same as "Last Sign-In"
1 parent c9ef03a commit 352a50d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

routers/web/explore/user.go

+4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions,
6868
orderBy = "`user`.updated_unix ASC"
6969
case "reversealphabetically":
7070
orderBy = "`user`.name DESC"
71+
case "lastlogin":
72+
orderBy = "`user`.last_login_unix ASC"
73+
case "reverselastlogin":
74+
orderBy = "`user`.last_login_unix DESC"
7175
case UserSearchDefaultSortType: // "alphabetically"
7276
default:
7377
orderBy = "`user`.name ASC"

templates/admin/user/list.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
<th>{{.locale.Tr "admin.users.2fa"}}</th>
7777
<th>{{.locale.Tr "admin.users.repos"}}</th>
7878
<th>{{.locale.Tr "admin.users.created"}}</th>
79-
<th data-sortt-asc="leastupdate" data-sortt-desc="recentupdate">
79+
<th data-sortt-asc="lastlogin" data-sortt-desc="reverselastlogin">
8080
{{.locale.Tr "admin.users.last_login"}}
81-
{{SortArrow "leastupdate" "recentupdate" $.SortType false}}
81+
{{SortArrow "lastlogin" "reverselastlogin" $.SortType false}}
8282
</th>
8383
<th>{{.locale.Tr "admin.users.edit"}}</th>
8484
</tr>

0 commit comments

Comments
 (0)