Fossil SCM

Do not show the numeric user ids on the /setup_ulist page. The login name is sufficient. On the /setup_uedit page, provide a link to an access log for that particular user.

drh 2018-01-12 14:30 trunk
Commit e85eff263012ab65409ff766c67bd11b8c2a9dff11a35cc3881fcd1b221b901c
2 files changed +7 -7 +6 -1
+7 -7
--- src/setup.c
+++ src/setup.c
@@ -164,11 +164,11 @@
164164
style_submenu_element("Log", "access_log");
165165
style_submenu_element("Help", "setup_ulist_notes");
166166
style_header("User List");
167167
@ <table border=1 cellpadding=2 cellspacing=0 class='userTable'>
168168
@ <thead><tr>
169
- @ <th>UID <th>Category
169
+ @ <th>Category
170170
@ <th>Capabilities (<a href='%R/setup_ucap_list'>key</a>)
171171
@ <th>Info <th>Last Change</tr></thead>
172172
@ <tbody>
173173
db_prepare(&s,
174174
"SELECT uid, login, cap, date(mtime,'unixepoch')"
@@ -180,11 +180,10 @@
180180
int uid = db_column_int(&s, 0);
181181
const char *zLogin = db_column_text(&s, 1);
182182
const char *zCap = db_column_text(&s, 2);
183183
const char *zDate = db_column_text(&s, 4);
184184
@ <tr>
185
- @ <td><a href='setup_uedit?id=%d(uid)'>%d(uid)</a>
186185
@ <td><a href='setup_uedit?id=%d(uid)'>%h(zLogin)</a>
187186
@ <td>%h(zCap)
188187
189188
if( fossil_strcmp(zLogin,"anonymous")==0 ){
190189
@ <td>All logged-in users
@@ -209,24 +208,25 @@
209208
style_header("Users With Capabilities \"%h\"", zWith);
210209
}
211210
@ </tbody></table>
212211
@ <div class='section'>Users</div>
213212
@ <table border=1 cellpadding=2 cellspacing=0 class='userTable sortable' \
214
- @ data-column-types='nktxTTK' data-init-sort='2'>
213
+ @ data-column-types='ktxTTK' data-init-sort='2'>
215214
@ <thead><tr>
216
- @ <th>ID<th>Login Name<th>Caps<th>Info<th>Date<th>Expire<th>Last Login</tr></thead>
215
+ @ <th>Login Name<th>Caps<th>Info<th>Date<th>Expire<th>Last Login</tr></thead>
217216
@ <tbody>
218217
db_multi_exec(
219
- "CREATE TEMP TABLE lastAccess(uname TEXT PRIMARY KEY, atime REAL) WITHOUT ROWID;"
218
+ "CREATE TEMP TABLE lastAccess(uname TEXT PRIMARY KEY, atime REAL) WITHOUT ROWID;"
220219
);
221220
if( db_table_exists("repository","accesslog") ){
222221
db_multi_exec(
223222
"INSERT INTO lastAccess(uname, atime)"
224223
" SELECT uname, max(mtime) FROM ("
225224
" SELECT uname, mtime FROM accesslog WHERE success"
226225
" UNION ALL"
227
- " SELECT login AS uname, rcvfrom.mtime AS mtime FROM rcvfrom JOIN user USING(uid))"
226
+ " SELECT login AS uname, rcvfrom.mtime AS mtime"
227
+ " FROM rcvfrom JOIN user USING(uid))"
228228
" GROUP BY 1;"
229229
);
230230
}
231231
if( zWith && zWith[0] ){
232232
zWith = mprintf(" AND cap GLOB '*[%q]*'", zWith);
@@ -256,11 +256,10 @@
256256
char *zAge = 0;
257257
if( rATime>0.0 ){
258258
zAge = human_readable_age(rNow - rATime);
259259
}
260260
@ <tr>
261
- @ <td><a href='setup_uedit?id=%d(uid)'>%d(uid)</a>
262261
@ <td data-sortkey='%h(zSortKey)'><a href='setup_uedit?id=%d(uid)'>%h(zLogin)</a>
263262
@ <td>%h(zCap)
264263
@ <td>%h(zInfo)
265264
@ <td>%h(zDate?zDate:"")
266265
@ <td>%h(zExp?zExp:"")
@@ -604,10 +603,11 @@
604603
/* Begin generating the page
605604
*/
606605
style_submenu_element("Cancel", cgi_referer("setup_ulist"));
607606
if( uid ){
608607
style_header("Edit User %h", zLogin);
608
+ style_submenu_element("Access Log", "%R/access_log?u=%t", zLogin);
609609
}else{
610610
style_header("Add A New User");
611611
}
612612
@ <div class="ueditCapBox">
613613
@ <form action="%s(g.zPath)" method="post"><div>
614614
--- src/setup.c
+++ src/setup.c
@@ -164,11 +164,11 @@
164 style_submenu_element("Log", "access_log");
165 style_submenu_element("Help", "setup_ulist_notes");
166 style_header("User List");
167 @ <table border=1 cellpadding=2 cellspacing=0 class='userTable'>
168 @ <thead><tr>
169 @ <th>UID <th>Category
170 @ <th>Capabilities (<a href='%R/setup_ucap_list'>key</a>)
171 @ <th>Info <th>Last Change</tr></thead>
172 @ <tbody>
173 db_prepare(&s,
174 "SELECT uid, login, cap, date(mtime,'unixepoch')"
@@ -180,11 +180,10 @@
180 int uid = db_column_int(&s, 0);
181 const char *zLogin = db_column_text(&s, 1);
182 const char *zCap = db_column_text(&s, 2);
183 const char *zDate = db_column_text(&s, 4);
184 @ <tr>
185 @ <td><a href='setup_uedit?id=%d(uid)'>%d(uid)</a>
186 @ <td><a href='setup_uedit?id=%d(uid)'>%h(zLogin)</a>
187 @ <td>%h(zCap)
188
189 if( fossil_strcmp(zLogin,"anonymous")==0 ){
190 @ <td>All logged-in users
@@ -209,24 +208,25 @@
209 style_header("Users With Capabilities \"%h\"", zWith);
210 }
211 @ </tbody></table>
212 @ <div class='section'>Users</div>
213 @ <table border=1 cellpadding=2 cellspacing=0 class='userTable sortable' \
214 @ data-column-types='nktxTTK' data-init-sort='2'>
215 @ <thead><tr>
216 @ <th>ID<th>Login Name<th>Caps<th>Info<th>Date<th>Expire<th>Last Login</tr></thead>
217 @ <tbody>
218 db_multi_exec(
219 "CREATE TEMP TABLE lastAccess(uname TEXT PRIMARY KEY, atime REAL) WITHOUT ROWID;"
220 );
221 if( db_table_exists("repository","accesslog") ){
222 db_multi_exec(
223 "INSERT INTO lastAccess(uname, atime)"
224 " SELECT uname, max(mtime) FROM ("
225 " SELECT uname, mtime FROM accesslog WHERE success"
226 " UNION ALL"
227 " SELECT login AS uname, rcvfrom.mtime AS mtime FROM rcvfrom JOIN user USING(uid))"
 
228 " GROUP BY 1;"
229 );
230 }
231 if( zWith && zWith[0] ){
232 zWith = mprintf(" AND cap GLOB '*[%q]*'", zWith);
@@ -256,11 +256,10 @@
256 char *zAge = 0;
257 if( rATime>0.0 ){
258 zAge = human_readable_age(rNow - rATime);
259 }
260 @ <tr>
261 @ <td><a href='setup_uedit?id=%d(uid)'>%d(uid)</a>
262 @ <td data-sortkey='%h(zSortKey)'><a href='setup_uedit?id=%d(uid)'>%h(zLogin)</a>
263 @ <td>%h(zCap)
264 @ <td>%h(zInfo)
265 @ <td>%h(zDate?zDate:"")
266 @ <td>%h(zExp?zExp:"")
@@ -604,10 +603,11 @@
604 /* Begin generating the page
605 */
606 style_submenu_element("Cancel", cgi_referer("setup_ulist"));
607 if( uid ){
608 style_header("Edit User %h", zLogin);
 
609 }else{
610 style_header("Add A New User");
611 }
612 @ <div class="ueditCapBox">
613 @ <form action="%s(g.zPath)" method="post"><div>
614
--- src/setup.c
+++ src/setup.c
@@ -164,11 +164,11 @@
164 style_submenu_element("Log", "access_log");
165 style_submenu_element("Help", "setup_ulist_notes");
166 style_header("User List");
167 @ <table border=1 cellpadding=2 cellspacing=0 class='userTable'>
168 @ <thead><tr>
169 @ <th>Category
170 @ <th>Capabilities (<a href='%R/setup_ucap_list'>key</a>)
171 @ <th>Info <th>Last Change</tr></thead>
172 @ <tbody>
173 db_prepare(&s,
174 "SELECT uid, login, cap, date(mtime,'unixepoch')"
@@ -180,11 +180,10 @@
180 int uid = db_column_int(&s, 0);
181 const char *zLogin = db_column_text(&s, 1);
182 const char *zCap = db_column_text(&s, 2);
183 const char *zDate = db_column_text(&s, 4);
184 @ <tr>
 
185 @ <td><a href='setup_uedit?id=%d(uid)'>%h(zLogin)</a>
186 @ <td>%h(zCap)
187
188 if( fossil_strcmp(zLogin,"anonymous")==0 ){
189 @ <td>All logged-in users
@@ -209,24 +208,25 @@
208 style_header("Users With Capabilities \"%h\"", zWith);
209 }
210 @ </tbody></table>
211 @ <div class='section'>Users</div>
212 @ <table border=1 cellpadding=2 cellspacing=0 class='userTable sortable' \
213 @ data-column-types='ktxTTK' data-init-sort='2'>
214 @ <thead><tr>
215 @ <th>Login Name<th>Caps<th>Info<th>Date<th>Expire<th>Last Login</tr></thead>
216 @ <tbody>
217 db_multi_exec(
218 "CREATE TEMP TABLE lastAccess(uname TEXT PRIMARY KEY, atime REAL) WITHOUT ROWID;"
219 );
220 if( db_table_exists("repository","accesslog") ){
221 db_multi_exec(
222 "INSERT INTO lastAccess(uname, atime)"
223 " SELECT uname, max(mtime) FROM ("
224 " SELECT uname, mtime FROM accesslog WHERE success"
225 " UNION ALL"
226 " SELECT login AS uname, rcvfrom.mtime AS mtime"
227 " FROM rcvfrom JOIN user USING(uid))"
228 " GROUP BY 1;"
229 );
230 }
231 if( zWith && zWith[0] ){
232 zWith = mprintf(" AND cap GLOB '*[%q]*'", zWith);
@@ -256,11 +256,10 @@
256 char *zAge = 0;
257 if( rATime>0.0 ){
258 zAge = human_readable_age(rNow - rATime);
259 }
260 @ <tr>
 
261 @ <td data-sortkey='%h(zSortKey)'><a href='setup_uedit?id=%d(uid)'>%h(zLogin)</a>
262 @ <td>%h(zCap)
263 @ <td>%h(zInfo)
264 @ <td>%h(zDate?zDate:"")
265 @ <td>%h(zExp?zExp:"")
@@ -604,10 +603,11 @@
603 /* Begin generating the page
604 */
605 style_submenu_element("Cancel", cgi_referer("setup_ulist"));
606 if( uid ){
607 style_header("Edit User %h", zLogin);
608 style_submenu_element("Access Log", "%R/access_log?u=%t", zLogin);
609 }else{
610 style_header("Add A New User");
611 }
612 @ <div class="ueditCapBox">
613 @ <form action="%s(g.zPath)" method="post"><div>
614
+6 -1
--- src/user.c
+++ src/user.c
@@ -634,10 +634,11 @@
634634
*/
635635
void access_log_page(void){
636636
int y = atoi(PD("y","3"));
637637
int n = atoi(PD("n","200"));
638638
int skip = atoi(PD("o","0"));
639
+ const char *zUser = P("u");
639640
Blob sql;
640641
Stmt q;
641642
int cnt = 0;
642643
int rc;
643644
int fLogEnabled;
@@ -673,11 +674,15 @@
673674
blob_zero(&sql);
674675
blob_append_sql(&sql,
675676
"SELECT uname, ipaddr, datetime(mtime,toLocal()), success"
676677
" FROM accesslog"
677678
);
678
- if( y==1 ){
679
+ if( zUser ){
680
+ blob_append_sql(&sql, " WHERE uname=%Q", zUser);
681
+ n = 1000000000;
682
+ skip = 0;
683
+ }else if( y==1 ){
679684
blob_append(&sql, " WHERE success", -1);
680685
}else if( y==2 ){
681686
blob_append(&sql, " WHERE NOT success", -1);
682687
}
683688
blob_append_sql(&sql," ORDER BY rowid DESC LIMIT %d OFFSET %d", n+1, skip);
684689
--- src/user.c
+++ src/user.c
@@ -634,10 +634,11 @@
634 */
635 void access_log_page(void){
636 int y = atoi(PD("y","3"));
637 int n = atoi(PD("n","200"));
638 int skip = atoi(PD("o","0"));
 
639 Blob sql;
640 Stmt q;
641 int cnt = 0;
642 int rc;
643 int fLogEnabled;
@@ -673,11 +674,15 @@
673 blob_zero(&sql);
674 blob_append_sql(&sql,
675 "SELECT uname, ipaddr, datetime(mtime,toLocal()), success"
676 " FROM accesslog"
677 );
678 if( y==1 ){
 
 
 
 
679 blob_append(&sql, " WHERE success", -1);
680 }else if( y==2 ){
681 blob_append(&sql, " WHERE NOT success", -1);
682 }
683 blob_append_sql(&sql," ORDER BY rowid DESC LIMIT %d OFFSET %d", n+1, skip);
684
--- src/user.c
+++ src/user.c
@@ -634,10 +634,11 @@
634 */
635 void access_log_page(void){
636 int y = atoi(PD("y","3"));
637 int n = atoi(PD("n","200"));
638 int skip = atoi(PD("o","0"));
639 const char *zUser = P("u");
640 Blob sql;
641 Stmt q;
642 int cnt = 0;
643 int rc;
644 int fLogEnabled;
@@ -673,11 +674,15 @@
674 blob_zero(&sql);
675 blob_append_sql(&sql,
676 "SELECT uname, ipaddr, datetime(mtime,toLocal()), success"
677 " FROM accesslog"
678 );
679 if( zUser ){
680 blob_append_sql(&sql, " WHERE uname=%Q", zUser);
681 n = 1000000000;
682 skip = 0;
683 }else if( y==1 ){
684 blob_append(&sql, " WHERE success", -1);
685 }else if( y==2 ){
686 blob_append(&sql, " WHERE NOT success", -1);
687 }
688 blob_append_sql(&sql," ORDER BY rowid DESC LIMIT %d OFFSET %d", n+1, skip);
689

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button