updated layout for small screens - colapsable sidepanel, fix issue with link to favicon when url_prefix is used
This commit is contained in:
@@ -31,6 +31,7 @@ func (h *Handlers) LoginPage(c *gin.Context) {
|
||||
returnTo := c.Query("return_to")
|
||||
c.HTML(http.StatusOK, "login", gin.H{
|
||||
"app_name": h.config.AppName,
|
||||
"LoginAndEdits": h.config.LoginAndEdits,
|
||||
"csrf_token": token,
|
||||
"return_to": returnTo,
|
||||
"ContentTemplate": "login_content",
|
||||
@@ -143,6 +144,7 @@ func (h *Handlers) MFALoginPage(c *gin.Context) {
|
||||
token, _ := c.Get("csrf_token")
|
||||
c.HTML(http.StatusOK, "mfa", gin.H{
|
||||
"app_name": h.config.AppName,
|
||||
"LoginAndEdits": h.config.LoginAndEdits,
|
||||
"csrf_token": token,
|
||||
"ContentTemplate": "mfa_content",
|
||||
"ScriptsTemplate": "mfa_scripts",
|
||||
@@ -159,6 +161,7 @@ func (h *Handlers) MFALoginVerify(c *gin.Context) {
|
||||
h.recordFailedAttempt(c, "mfa", "", nil)
|
||||
c.HTML(http.StatusUnauthorized, "mfa", gin.H{
|
||||
"app_name": h.config.AppName,
|
||||
"LoginAndEdits": h.config.LoginAndEdits,
|
||||
"csrf_token": token,
|
||||
"error": "Invalid code format",
|
||||
"ContentTemplate": "mfa_content",
|
||||
@@ -177,7 +180,7 @@ func (h *Handlers) MFALoginVerify(c *gin.Context) {
|
||||
var secret string
|
||||
if err := h.authSvc.DB.QueryRow(`SELECT mfa_secret FROM users WHERE id = ?`, uid).Scan(&secret); err != nil || secret == "" {
|
||||
h.recordFailedAttempt(c, "mfa", "", &uid)
|
||||
c.HTML(http.StatusUnauthorized, "mfa", gin.H{"error": "MFA not enabled", "Page": "mfa", "ContentTemplate": "mfa_content", "ScriptsTemplate": "mfa_scripts", "app_name": h.config.AppName})
|
||||
c.HTML(http.StatusUnauthorized, "mfa", gin.H{"error": "MFA not enabled", "Page": "mfa", "ContentTemplate": "mfa_content", "ScriptsTemplate": "mfa_scripts", "app_name": h.config.AppName, "LoginAndEdits": h.config.LoginAndEdits})
|
||||
return
|
||||
}
|
||||
if !verifyTOTP(secret, code, time.Now()) {
|
||||
@@ -185,6 +188,7 @@ func (h *Handlers) MFALoginVerify(c *gin.Context) {
|
||||
h.recordFailedAttempt(c, "mfa", "", &uid)
|
||||
c.HTML(http.StatusUnauthorized, "mfa", gin.H{
|
||||
"app_name": h.config.AppName,
|
||||
"LoginAndEdits": h.config.LoginAndEdits,
|
||||
"csrf_token": token,
|
||||
"error": "Invalid code",
|
||||
"ContentTemplate": "mfa_content",
|
||||
@@ -223,7 +227,7 @@ func (h *Handlers) ProfileMFASetupPage(c *gin.Context) {
|
||||
// create new enrollment
|
||||
s, e := generateBase32Secret()
|
||||
if e != nil {
|
||||
c.HTML(http.StatusInternalServerError, "error", gin.H{"error": "Failed to create enrollment", "Page": "error", "ContentTemplate": "error_content", "ScriptsTemplate": "error_scripts", "app_name": h.config.AppName})
|
||||
c.HTML(http.StatusInternalServerError, "error", gin.H{"error": "Failed to create enrollment", "Page": "error", "ContentTemplate": "error_content", "ScriptsTemplate": "error_scripts", "app_name": h.config.AppName, "LoginAndEdits": h.config.LoginAndEdits})
|
||||
return
|
||||
}
|
||||
_, _ = h.authSvc.DB.Exec(`INSERT OR REPLACE INTO mfa_enrollments (user_id, secret) VALUES (?, ?)`, *uidPtr, s)
|
||||
@@ -240,6 +244,7 @@ func (h *Handlers) ProfileMFASetupPage(c *gin.Context) {
|
||||
notesTree, _ := utils.BuildTreeStructure(h.config.NotesDir, h.config.NotesDirHideSidepane, h.config)
|
||||
c.HTML(http.StatusOK, "mfa_setup", gin.H{
|
||||
"app_name": h.config.AppName,
|
||||
"LoginAndEdits": h.config.LoginAndEdits,
|
||||
"notes_tree": notesTree,
|
||||
"active_path": []string{},
|
||||
"current_note": nil,
|
||||
@@ -342,6 +347,7 @@ func (h *Handlers) LoginPost(c *gin.Context) {
|
||||
h.recordFailedAttempt(c, "password", username, nil)
|
||||
c.HTML(http.StatusUnauthorized, "login", gin.H{
|
||||
"app_name": h.config.AppName,
|
||||
"LoginAndEdits": h.config.LoginAndEdits,
|
||||
"csrf_token": token,
|
||||
"error": err.Error(),
|
||||
"return_to": returnTo,
|
||||
|
||||
Reference in New Issue
Block a user