Transition to new logger

This commit is contained in:
Melon 2024-05-13 20:25:44 +01:00
parent 06c036817d
commit e0fa521657
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
12 changed files with 37 additions and 37 deletions

View File

@ -17,6 +17,7 @@ SELECT subject,
name, name,
username, username,
picture, picture,
website,
email, email,
email_verified, email_verified,
role, role,
@ -31,6 +32,7 @@ type GetUserListRow struct {
Name string `json:"name"` Name string `json:"name"`
Username string `json:"username"` Username string `json:"username"`
Picture string `json:"picture"` Picture string `json:"picture"`
Website string `json:"website"`
Email string `json:"email"` Email string `json:"email"`
EmailVerified bool `json:"email_verified"` EmailVerified bool `json:"email_verified"`
Role types.UserRole `json:"role"` Role types.UserRole `json:"role"`
@ -52,6 +54,7 @@ func (q *Queries) GetUserList(ctx context.Context, offset int64) ([]GetUserListR
&i.Name, &i.Name,
&i.Username, &i.Username,
&i.Picture, &i.Picture,
&i.Website,
&i.Email, &i.Email,
&i.EmailVerified, &i.EmailVerified,
&i.Role, &i.Role,
@ -90,7 +93,7 @@ func (q *Queries) UpdateUserRole(ctx context.Context, arg UpdateUserRoleParams)
} }
const userEmailExists = `-- name: UserEmailExists :one const userEmailExists = `-- name: UserEmailExists :one
SELECT CAST(EXISTS(SELECT 1 FROM users WHERE email = ? AND email_verified = 1) AS BOOLEAN) AS email_exists SELECT EXISTS(SELECT 1 FROM users WHERE email = ? AND email_verified = 1) == 1 AS email_exists
` `
func (q *Queries) UserEmailExists(ctx context.Context, email string) (bool, error) { func (q *Queries) UserEmailExists(ctx context.Context, email string) (bool, error) {

View File

@ -3,6 +3,7 @@ SELECT subject,
name, name,
username, username,
picture, picture,
website,
email, email,
email_verified, email_verified,
role, role,
@ -23,4 +24,4 @@ SET email_verified = 1
WHERE subject = ?; WHERE subject = ?;
-- name: UserEmailExists :one -- name: UserEmailExists :one
SELECT CAST(EXISTS(SELECT 1 FROM users WHERE email = ? AND email_verified = 1) AS BOOLEAN) AS email_exists; SELECT EXISTS(SELECT 1 FROM users WHERE email = ? AND email_verified = 1) == 1 AS email_exists;

View File

@ -1,5 +1,5 @@
-- name: HasUser :one -- name: HasUser :one
SELECT CAST(count(subject) AS BOOLEAN) AS hasUser SELECT count(subject) > 0 AS hasUser
FROM users; FROM users;
-- name: addUser :exec -- name: addUser :exec
@ -7,7 +7,7 @@ INSERT INTO users (subject, name, username, password, email, email_verified, rol
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?); VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
-- name: checkLogin :one -- name: checkLogin :one
SELECT subject, name, password, CAST(EXISTS(SELECT 1 FROM otp WHERE otp.subject = users.subject) AS BOOLEAN) AS has_otp, email, email_verified SELECT subject, name, password, EXISTS(SELECT 1 FROM otp WHERE otp.subject = users.subject) == 1 AS has_otp, email, email_verified
FROM users FROM users
WHERE username = ? WHERE username = ?
LIMIT 1; LIMIT 1;
@ -69,7 +69,7 @@ FROM otp
WHERE subject = ?; WHERE subject = ?;
-- name: HasOtp :one -- name: HasOtp :one
SELECT CAST(EXISTS(SELECT 1 FROM otp WHERE subject = ?) AS BOOLEAN); SELECT EXISTS(SELECT 1 FROM otp WHERE subject = ?) == 1 as hasOtp;
-- name: GetUserEmail :one -- name: GetUserEmail :one
SELECT email SELECT email

View File

@ -114,18 +114,18 @@ func (q *Queries) GetUserRole(ctx context.Context, subject string) (types.UserRo
} }
const hasOtp = `-- name: HasOtp :one const hasOtp = `-- name: HasOtp :one
SELECT CAST(EXISTS(SELECT 1 FROM otp WHERE subject = ?) AS BOOLEAN) SELECT EXISTS(SELECT 1 FROM otp WHERE subject = ?) == 1 as hasOtp
` `
func (q *Queries) HasOtp(ctx context.Context, subject string) (bool, error) { func (q *Queries) HasOtp(ctx context.Context, subject string) (bool, error) {
row := q.db.QueryRowContext(ctx, hasOtp, subject) row := q.db.QueryRowContext(ctx, hasOtp, subject)
var column_1 bool var hasotp bool
err := row.Scan(&column_1) err := row.Scan(&hasotp)
return column_1, err return hasotp, err
} }
const hasUser = `-- name: HasUser :one const hasUser = `-- name: HasUser :one
SELECT CAST(count(subject) AS BOOLEAN) AS hasUser SELECT count(subject) > 0 AS hasUser
FROM users FROM users
` `
@ -252,7 +252,7 @@ func (q *Queries) changeUserPassword(ctx context.Context, arg changeUserPassword
} }
const checkLogin = `-- name: checkLogin :one const checkLogin = `-- name: checkLogin :one
SELECT subject, name, password, CAST(EXISTS(SELECT 1 FROM otp WHERE otp.subject = users.subject) AS BOOLEAN) AS has_otp, email, email_verified SELECT subject, name, password, EXISTS(SELECT 1 FROM otp WHERE otp.subject = users.subject) == 1 AS has_otp, email, email_verified
FROM users FROM users
WHERE username = ? WHERE username = ?
LIMIT 1 LIMIT 1

16
go.sum
View File

@ -5,8 +5,7 @@ github.com/1f349/mjwt v0.2.5 h1:IxjLaali22ayTzZ628lH7j0JDdYJoj6+CJ/VktCqtXQ=
github.com/1f349/mjwt v0.2.5/go.mod h1:KEs6jd9JjWrQW+8feP2pGAU7pdA3aYTqjkT/YQr73PU= github.com/1f349/mjwt v0.2.5/go.mod h1:KEs6jd9JjWrQW+8feP2pGAU7pdA3aYTqjkT/YQr73PU=
github.com/1f349/overlapfs v0.0.1 h1:LAxBolrXFAgU0yqZtXg/C/aaPq3eoQSPpBc49BHuTp0= github.com/1f349/overlapfs v0.0.1 h1:LAxBolrXFAgU0yqZtXg/C/aaPq3eoQSPpBc49BHuTp0=
github.com/1f349/overlapfs v0.0.1/go.mod h1:I6aItQycr7nrzplmfNXp/QF9tTmKRSgY3fXmu/7Ky2o= github.com/1f349/overlapfs v0.0.1/go.mod h1:I6aItQycr7nrzplmfNXp/QF9tTmKRSgY3fXmu/7Ky2o=
github.com/1f349/violet v0.0.13 h1:lJpTz15Ea83Uc1VAISXTjtKuzr8Pe8NM4cMGp3Aiyhk= github.com/1f349/violet v0.0.14 h1:MpBZ4n1dJjdiIwYMTfh0PBIFll3kjqowxR6DLasafqE=
github.com/1f349/violet v0.0.13/go.mod h1:Ga5/hWqI+EkR6J1mAMNzs7aJhuGcA89XFqgQaDXC7Jo=
github.com/1f349/violet v0.0.14/go.mod h1:iAREhm+wxnGXkmuvmBhOuhUx2T7/5w7stLYNgQGbqC8= github.com/1f349/violet v0.0.14/go.mod h1:iAREhm+wxnGXkmuvmBhOuhUx2T7/5w7stLYNgQGbqC8=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
@ -91,12 +90,12 @@ github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
@ -136,8 +135,6 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
@ -227,8 +224,6 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@ -285,9 +280,8 @@ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miE
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@ -9,7 +9,7 @@
<h1>{{.ServiceName}}</h1> <h1>{{.ServiceName}}</h1>
</header> </header>
<main> <main>
<div>Logged in as: {{.User.Name}} ({{.User.Sub}})</div> <div>Logged in as: {{.User.Name}} ({{.User.Subject}})</div>
<div> <div>
<form method="POST" action="/edit"> <form method="POST" action="/edit">
<input type="hidden" name="nonce" value="{{.Nonce}}"> <input type="hidden" name="nonce" value="{{.Nonce}}">
@ -43,7 +43,7 @@
</div> </div>
<div> <div>
<label for="field_zoneinfo">Time Zone:</label> <label for="field_zoneinfo">Time Zone:</label>
<input type="text" name="zoneinfo" id="field_zoneinfo" value="{{.User.ZoneInfo}}" list="list_zoneinfo"> <input type="text" name="zoneinfo" id="field_zoneinfo" value="{{.User.Zoneinfo}}" list="list_zoneinfo">
<datalist id="list_zoneinfo"> <datalist id="list_zoneinfo">
{{range .ListZoneInfo}} {{range .ListZoneInfo}}
<option value="{{.}}"></option> <option value="{{.}}"></option>

View File

@ -9,7 +9,7 @@
<h1>{{.ServiceName}}</h1> <h1>{{.ServiceName}}</h1>
</header> </header>
<main> <main>
<div>Logged in as: {{.User.Name}} ({{.User.Sub}})</div> <div>Logged in as: {{.User.Name}} ({{.User.Subject}})</div>
<div> <div>
<form method="GET" action="/edit"> <form method="GET" action="/edit">
<button type="submit">Edit Profile</button> <button type="submit">Edit Profile</button>

View File

@ -46,9 +46,9 @@
<form method="POST" action="/manage/apps"> <form method="POST" action="/manage/apps">
<input type="hidden" name="action" value="edit"/> <input type="hidden" name="action" value="edit"/>
<input type="hidden" name="offset" value="{{.Offset}}"/> <input type="hidden" name="offset" value="{{.Offset}}"/>
<input type="hidden" name="subject" value="{{.Edit.Sub}}"/> <input type="hidden" name="subject" value="{{.Edit.Subject}}"/>
<div> <div>
<label>ID: {{.Edit.Sub}}</label> <label>ID: {{.Edit.Subject}}</label>
</div> </div>
<div> <div>
<label for="field_name">Name:</label> <label for="field_name">Name:</label>
@ -96,23 +96,23 @@
<tbody> <tbody>
{{range .Apps}} {{range .Apps}}
<tr> <tr>
<td>{{.Sub}}</td> <td>{{.Subject}}</td>
<td>{{.Name}}</td> <td>{{.Name}}</td>
<td>{{.Domain}}</td> <td>{{.Domain}}</td>
<td>{{.Public}}</td> <td>{{.Public}}</td>
<td>{{.SSO}}</td> <td>{{.Sso}}</td>
<td>{{.Active}}</td> <td>{{.Active}}</td>
<td>{{.Owner}}</td> <td>{{.Owner}}</td>
<td> <td>
<form method="GET" action="/manage/apps"> <form method="GET" action="/manage/apps">
<input type="hidden" name="offset" value="{{$.Offset}}"/> <input type="hidden" name="offset" value="{{$.Offset}}"/>
<input type="hidden" name="edit" value="{{.Sub}}"/> <input type="hidden" name="edit" value="{{.Subject}}"/>
<button type="submit">Edit</button> <button type="submit">Edit</button>
</form> </form>
<form method="POST" action="/manage/apps?offset={{$.Offset}}"> <form method="POST" action="/manage/apps?offset={{$.Offset}}">
<input type="hidden" name="action" value="secret"/> <input type="hidden" name="action" value="secret"/>
<input type="hidden" name="offset" value="{{$.Offset}}"/> <input type="hidden" name="offset" value="{{$.Offset}}"/>
<input type="hidden" name="subject" value="{{.Sub}}"/> <input type="hidden" name="subject" value="{{.Subject}}"/>
<button type="submit">Reset Secret</button> <button type="submit">Reset Secret</button>
</form> </form>
</td> </td>

View File

@ -18,9 +18,9 @@
<form method="POST" action="/manage/users"> <form method="POST" action="/manage/users">
<input type="hidden" name="action" value="edit"/> <input type="hidden" name="action" value="edit"/>
<input type="hidden" name="offset" value="{{.Offset}}"/> <input type="hidden" name="offset" value="{{.Offset}}"/>
<input type="hidden" name="subject" value="{{.Edit.Sub}}"/> <input type="hidden" name="subject" value="{{.Edit.Subject}}"/>
<div> <div>
<label>ID: {{.Edit.Sub}}</label> <label>ID: {{.Edit.Subject}}</label>
</div> </div>
<div> <div>
<label for="field_name">Name:</label> <label for="field_name">Name:</label>
@ -71,7 +71,7 @@
<tbody> <tbody>
{{range .Users}} {{range .Users}}
<tr> <tr>
<td>{{.Sub}}</td> <td>{{.Subject}}</td>
<td>{{.Name}}</td> <td>{{.Name}}</td>
<td>{{.Username}}</td> <td>{{.Username}}</td>
<td> <td>
@ -92,12 +92,12 @@
<th>{{.UpdatedAt}}</th> <th>{{.UpdatedAt}}</th>
<td>{{.Active}}</td> <td>{{.Active}}</td>
<td> <td>
{{if eq $.CurrentAdmin .Sub}} {{if eq $.CurrentAdmin .Subject}}
<span></span> <span></span>
{{else}} {{else}}
<form method="GET" action="/manage/users"> <form method="GET" action="/manage/users">
<input type="hidden" name="offset" value="{{$.Offset}}"/> <input type="hidden" name="offset" value="{{$.Offset}}"/>
<input type="hidden" name="edit" value="{{.Sub}}"/> <input type="hidden" name="edit" value="{{.Subject}}"/>
<button type="submit">Edit</button> <button type="submit">Edit</button>
</form> </form>
<form method="POST" action="/reset-password"> <form method="POST" action="/reset-password">

View File

@ -41,6 +41,7 @@ func LoadPages(wd string) (err error) {
} }
func RenderPageTemplate(wr io.Writer, name string, data any) { func RenderPageTemplate(wr io.Writer, name string, data any) {
logger.Logger.Helper()
err := wwwTemplates.ExecuteTemplate(wr, name+".go.html", data) err := wwwTemplates.ExecuteTemplate(wr, name+".go.html", data)
if err != nil { if err != nil {
logger.Logger.Warn("Failed to render page", "name", name, "err", err) logger.Logger.Warn("Failed to render page", "name", name, "err", err)

View File

@ -13,6 +13,7 @@ func (h *HttpServer) DbTx(rw http.ResponseWriter, action func(db *database.Queri
err := action(h.db) err := action(h.db)
if err != nil { if err != nil {
http.Error(rw, "Database error", http.StatusInternalServerError) http.Error(rw, "Database error", http.StatusInternalServerError)
logger.Logger.Helper()
logger.Logger.Warn("Database action error", "err", err) logger.Logger.Warn("Database action error", "err", err)
return true return true
} }

View File

@ -53,7 +53,7 @@ func (h *HttpServer) Home(rw http.ResponseWriter, req *http.Request, _ httproute
pages.RenderPageTemplate(rw, "index", map[string]any{ pages.RenderPageTemplate(rw, "index", map[string]any{
"ServiceName": h.conf.ServiceName, "ServiceName": h.conf.ServiceName,
"Auth": auth, "Auth": auth,
"User": userWithName, "User": database.User{Subject: auth.ID, Name: userWithName, Role: userRole},
"Nonce": lNonce, "Nonce": lNonce,
"OtpEnabled": hasTwoFactor, "OtpEnabled": hasTwoFactor,
"IsAdmin": userRole == types.RoleAdmin, "IsAdmin": userRole == types.RoleAdmin,