Compare commits

...

2 Commits

Author SHA1 Message Date
hyung-hwan 7f20612b94 fixed branding info 2026-07-08 19:17:57 +09:00
hyung-hwan 624f7bc7c6 fixed the 2fa chip issue in the active session page 2026-07-08 18:59:55 +09:00
9 changed files with 27 additions and 16 deletions
+5 -4
View File
@@ -60,7 +60,7 @@ func run() int {
cfg, err = codit.LoadConfigFilesWithEnvPrefix(configPaths, codit.EnvPrefixFromServerId(PROGRAM_NAME)) cfg, err = codit.LoadConfigFilesWithEnvPrefix(configPaths, codit.EnvPrefixFromServerId(PROGRAM_NAME))
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: load config - %v\n", err) fmt.Fprintf(os.Stderr, "ERROR: load config - %s\n", err.Error())
return 1 return 1
} }
if logFile != "" { if logFile != "" {
@@ -68,7 +68,7 @@ func run() int {
} }
logger, err = newLoggerFromConfig(PROGRAM_NAME, cfg) logger, err = newLoggerFromConfig(PROGRAM_NAME, cfg)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: init logger - %v\n", err) fmt.Fprintf(os.Stderr, "ERROR: init logger - %s\n", err.Error())
return 1 return 1
} }
defer logger.Close() defer logger.Close()
@@ -79,14 +79,15 @@ func run() int {
server, err = codit.NewServerWithId(&cfg, logger, PROGRAM_NAME) server, err = codit.NewServerWithId(&cfg, logger, PROGRAM_NAME)
if err != nil { if err != nil {
logger.Write("", codit.LOG_ERROR, "init app: %v", err) logger.Write("", codit.LOG_ERROR, "init app - %s", err.Error())
return 1 return 1
} }
defer server.Close() defer server.Close()
logger.Write("", codit.LOG_INFO, "started %s %s - %s", PROGRAM_NAME, PROGRAM_VERSION, server.InfoString())
err = server.ServeContext(ctx) err = server.ServeContext(ctx)
if err != nil { if err != nil {
logger.Write("", codit.LOG_ERROR, "server failed: %v", err) logger.Write("", codit.LOG_ERROR, "server failed - %s", err.Error())
return 1 return 1
} }
logger.Write("", codit.LOG_INFO, "shutdown complete - %s %s", PROGRAM_NAME, PROGRAM_VERSION) logger.Write("", codit.LOG_INFO, "shutdown complete - %s %s", PROGRAM_NAME, PROGRAM_VERSION)
+5 -2
View File
@@ -459,20 +459,23 @@ func (s *Store) ListActiveSessions(now int64) ([]models.GUISession, error) {
var out []models.GUISession var out []models.GUISession
var err error var err error
rows, err = s.Query(`SELECT s.id, u.public_id, u.username, u.display_name, u.is_admin, rows, err = s.Query(`SELECT s.id, u.public_id, u.username, u.display_name, u.is_admin,
s.created_at, s.expires_at, s.totp_verified, s.created_at, s.expires_at, COALESCE(t.enabled, 0), s.totp_verified,
CASE WHEN s.oidc_id_token != '' THEN 1 ELSE 0 END CASE WHEN s.oidc_id_token != '' THEN 1 ELSE 0 END
FROM sessions s JOIN users u ON u.id = s.user_id FROM sessions s JOIN users u ON u.id = s.user_id
LEFT JOIN user_totp t ON t.user_id = u.id
WHERE s.expires_at > ? WHERE s.expires_at > ?
ORDER BY s.created_at DESC`, now) ORDER BY s.created_at DESC`, now)
if err != nil { return nil, err } if err != nil { return nil, err }
defer rows.Close() defer rows.Close()
for rows.Next() { for rows.Next() {
var item models.GUISession var item models.GUISession
var totpEnabled int64
var totp int64 var totp int64
var oidc int64 var oidc int64
err = rows.Scan(&item.ID, &item.UserID, &item.Username, &item.DisplayName, &item.IsAdmin, err = rows.Scan(&item.ID, &item.UserID, &item.Username, &item.DisplayName, &item.IsAdmin,
&item.CreatedAt, &item.ExpiresAt, &totp, &oidc) &item.CreatedAt, &item.ExpiresAt, &totpEnabled, &totp, &oidc)
if err != nil { return nil, err } if err != nil { return nil, err }
item.TOTPEnabled = totpEnabled != 0
item.TOTPVerified = totp != 0 item.TOTPVerified = totp != 0
item.HasOIDC = oidc != 0 item.HasOIDC = oidc != 0
out = append(out, item) out = append(out, item)
+1
View File
@@ -10,6 +10,7 @@ type GUISession struct {
IsAdmin bool `json:"is_admin"` IsAdmin bool `json:"is_admin"`
CreatedAt int64 `json:"created_at"` CreatedAt int64 `json:"created_at"`
ExpiresAt int64 `json:"expires_at"` ExpiresAt int64 `json:"expires_at"`
TOTPEnabled bool `json:"totp_enabled"`
TOTPVerified bool `json:"totp_verified"` TOTPVerified bool `json:"totp_verified"`
HasOIDC bool `json:"has_oidc"` HasOIDC bool `json:"has_oidc"`
Current bool `json:"current"` Current bool `json:"current"`
+4
View File
@@ -747,6 +747,10 @@ func (app *Server) stopBackgroundManagers() {
if app.notify_relay != nil { app.notify_relay.Wait() } if app.notify_relay != nil { app.notify_relay.Wait() }
} }
func (app *Server) InfoString() string {
return fmt.Sprintf("%s (%s)", app.serverId, app.siteName)
}
func (app *Server) Serve() error { func (app *Server) Serve() error {
return app.ServeContext(context.Background()) return app.ServeContext(context.Background())
} }
+3 -3
View File
@@ -1,3 +1,3 @@
VITE_APP_SERVER_ID=codit VITE_APP_SERVER_ID=server
VITE_APP_SERVER_TITLE=Codit VITE_APP_SERVER_TITLE=Server
VITE_APP_SITE_NAME= VITE_APP_SITE_NAME=Site
+1
View File
@@ -1905,6 +1905,7 @@ export interface GUISession {
is_admin: boolean is_admin: boolean
created_at: number created_at: number
expires_at: number expires_at: number
totp_enabled: boolean
totp_verified: boolean totp_verified: boolean
has_oidc: boolean has_oidc: boolean
current: boolean current: boolean
+5 -5
View File
@@ -21,11 +21,11 @@ declare global {
const runtime = window.__APP_INFO__ const runtime = window.__APP_INFO__
export const defaultAppBrand: AppBrand = { export const defaultAppBrand: AppBrand = {
server_id: runtime?.server_id || import.meta.env.VITE_APP_SERVER_ID || 'codit', server_id: runtime?.server_id || import.meta.env.VITE_APP_SERVER_ID || 'server',
server_title: runtime?.server_title || import.meta.env.VITE_APP_SERVER_TITLE || 'Codit', server_title: runtime?.server_title || import.meta.env.VITE_APP_SERVER_TITLE || 'Server',
site_name: runtime?.site_name || import.meta.env.VITE_APP_SITE_NAME || 'Codit', site_name: runtime?.site_name || import.meta.env.VITE_APP_SITE_NAME || 'Site',
storagePrefix: runtime?.server_id || import.meta.env.VITE_APP_SERVER_ID || 'codit', storagePrefix: runtime?.server_id || import.meta.env.VITE_APP_SERVER_ID || 'server',
sanURIPrefix: `urn:${runtime?.server_id || import.meta.env.VITE_APP_SERVER_ID || 'codit'}:user:` sanURIPrefix: `urn:${runtime?.server_id || import.meta.env.VITE_APP_SERVER_ID || 'server'}:user:`
} }
export const BrandContext = createContext<AppBrand>(defaultAppBrand) export const BrandContext = createContext<AppBrand>(defaultAppBrand)
+1 -1
View File
@@ -102,7 +102,7 @@ export default function AdminSessionsPage() {
renderCell: (s) => ( renderCell: (s) => (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}> <Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<Chip size="small" variant="outlined" label={s.has_oidc ? 'OIDC' : 'password'} sx={{ height: 18 }} /> <Chip size="small" variant="outlined" label={s.has_oidc ? 'OIDC' : 'password'} sx={{ height: 18 }} />
{s.totp_verified ? <Chip size="small" variant="outlined" color="success" label="2FA" sx={{ height: 18 }} /> : null} {s.totp_enabled && s.totp_verified ? <Chip size="small" variant="outlined" color="success" label="2FA" sx={{ height: 18 }} /> : null}
</Box> </Box>
) )
}, },
+2 -1
View File
@@ -7,8 +7,9 @@ export default defineConfig({
{ {
// in the development, i want the same text replacement as backend/server.go // in the development, i want the same text replacement as backend/server.go
name: "replace-placeholder", name: "replace-placeholder",
apply: "serve", // only in the development server mode
transformIndexHtml(html) { transformIndexHtml(html) {
return html.replaceAll("%SERVER_ID%", "codit").replaceAll("%SERVER_NAME%", "Codit").replaceAll("%SITE_NAME%", "Codit Development Via Vite"); return html.replaceAll("%SERVER_ID%", "codit").replaceAll("%SERVER_TITLE%", "Codit").replaceAll("%SITE_NAME%", "Codit Development Via Vite");
} }
} }
], ],