Admin: ispravke AJAX toast-a za sve akcije korisnika i dozvola
- base.html: toast pri učitavanju stranice ako URL sadrži ?sacuvano=1 (pokriven i cross-page redirect) - admin.go: svih 9 SetFlash(uspeh) zamenjeno sa redirect ?sacuvano=1 (korisnici, profil, dozvole)
This commit is contained in:
@@ -126,8 +126,7 @@ func (h *Handler) AdminSacuvajKorisnika(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
middleware.SetFlash(w, r, h.DB, "uspeh", "Korisnik je uspešno kreiran.")
|
http.Redirect(w, r, "/admin/korisnici?sacuvano=1", http.StatusSeeOther)
|
||||||
http.Redirect(w, r, "/admin/korisnici", http.StatusSeeOther)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminToggleAktivan menja aktivan status korisnika
|
// AdminToggleAktivan menja aktivan status korisnika
|
||||||
@@ -172,8 +171,7 @@ func (h *Handler) AdminToggleAktivan(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
middleware.SetFlash(w, r, h.DB, "uspeh", "Promene su uspešno sačuvane.")
|
http.Redirect(w, r, "/admin/korisnici?sacuvano=1", http.StatusSeeOther)
|
||||||
http.Redirect(w, r, "/admin/korisnici", http.StatusSeeOther)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminPromeniUlogu menja ulogu korisnika
|
// AdminPromeniUlogu menja ulogu korisnika
|
||||||
@@ -234,8 +232,7 @@ func (h *Handler) AdminPromeniUlogu(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
middleware.SetFlash(w, r, h.DB, "uspeh", "Promene su uspešno sačuvane.")
|
http.Redirect(w, r, "/admin/korisnici?sacuvano=1", http.StatusSeeOther)
|
||||||
http.Redirect(w, r, "/admin/korisnici", http.StatusSeeOther)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminObrisiKorisnika briše korisnika sa ulogom radnik
|
// AdminObrisiKorisnika briše korisnika sa ulogom radnik
|
||||||
@@ -279,8 +276,7 @@ func (h *Handler) AdminObrisiKorisnika(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
middleware.SetFlash(w, r, h.DB, "uspeh", "Korisnik je obrisan.")
|
http.Redirect(w, r, "/admin/korisnici?sacuvano=1", http.StatusSeeOther)
|
||||||
http.Redirect(w, r, "/admin/korisnici", http.StatusSeeOther)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminProfil prikazuje stranicu profila
|
// AdminProfil prikazuje stranicu profila
|
||||||
@@ -406,8 +402,7 @@ func (h *Handler) AdminPromeniLozinku(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
middleware.SetFlash(w, r, h.DB, "uspeh", "Lozinka je uspešno promenjena.")
|
http.Redirect(w, r, "/admin/profil?sacuvano=1", http.StatusSeeOther)
|
||||||
http.Redirect(w, r, "/admin/profil", http.StatusSeeOther)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminTotpPokreni generiše TOTP tajnu i prikazuje QR kod
|
// AdminTotpPokreni generiše TOTP tajnu i prikazuje QR kod
|
||||||
@@ -529,8 +524,7 @@ func (h *Handler) AdminTotpDeaktivacija(w http.ResponseWriter, r *http.Request)
|
|||||||
// isključenjem 2FA brišemo i rezervne kodove
|
// isključenjem 2FA brišemo i rezervne kodove
|
||||||
_ = h.RezervniKodoviRepo.Obrisi(r.Context(), k.ID)
|
_ = h.RezervniKodoviRepo.Obrisi(r.Context(), k.ID)
|
||||||
|
|
||||||
middleware.SetFlash(w, r, h.DB, "uspeh", "Dvostepena verifikacija je isključena.")
|
http.Redirect(w, r, "/admin/profil?sacuvano=1", http.StatusSeeOther)
|
||||||
http.Redirect(w, r, "/admin/profil", http.StatusSeeOther)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminLoginIstorija prikazuje evidenciju prijava za datog korisnika
|
// AdminLoginIstorija prikazuje evidenciju prijava za datog korisnika
|
||||||
@@ -679,8 +673,7 @@ func (h *Handler) AdminDozvolePromeniUlogu(w http.ResponseWriter, r *http.Reques
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
middleware.SetFlash(w, r, h.DB, "uspeh", "Promene su uspešno sačuvane.")
|
http.Redirect(w, r, "/admin/dozvole?sacuvano=1", http.StatusSeeOther)
|
||||||
http.Redirect(w, r, "/admin/dozvole", http.StatusSeeOther)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminDozvoleSacuvaj prima POST i čuva promene dozvola za radnik i admin uloge
|
// AdminDozvoleSacuvaj prima POST i čuva promene dozvola za radnik i admin uloge
|
||||||
@@ -711,8 +704,7 @@ func (h *Handler) AdminDozvoleSacuvaj(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
middleware.SetFlash(w, r, h.DB, "uspeh", "Promene su uspešno sačuvane.")
|
http.Redirect(w, r, "/admin/dozvole?sacuvano=1", http.StatusSeeOther)
|
||||||
http.Redirect(w, r, "/admin/dozvole", http.StatusSeeOther)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdminDozvoleReset vraća sve dozvole na podrazumevane vrednosti — samo superadmin
|
// AdminDozvoleReset vraća sve dozvole na podrazumevane vrednosti — samo superadmin
|
||||||
@@ -727,6 +719,5 @@ func (h *Handler) AdminDozvoleReset(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Redirect(w, r, "/admin/dozvole", http.StatusSeeOther)
|
http.Redirect(w, r, "/admin/dozvole", http.StatusSeeOther)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
middleware.SetFlash(w, r, h.DB, "uspeh", "Dozvole su vraćene na podrazumevane vrednosti.")
|
http.Redirect(w, r, "/admin/dozvole?sacuvano=1", http.StatusSeeOther)
|
||||||
http.Redirect(w, r, "/admin/dozvole", http.StatusSeeOther)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,6 +318,16 @@
|
|||||||
f.appendChild(i);
|
f.appendChild(i);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// toast pri učitavanju stranice ako URL sadrži ?sacuvano=1 (cross-page redirect)
|
||||||
|
if (!window._ntechSacuvanoPrikazano && location.search.indexOf('sacuvano=1') !== -1) {
|
||||||
|
window._ntechSacuvanoPrikazano = true;
|
||||||
|
window.ntechToast('Sačuvano', 'uspeh');
|
||||||
|
var _p = new URLSearchParams(location.search);
|
||||||
|
_p.delete('sacuvano');
|
||||||
|
var _q = _p.toString() ? '?' + _p.toString() : '';
|
||||||
|
history.replaceState(null, '', location.pathname + _q + location.hash);
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelectorAll('[data-potvrda]').forEach(function(el) {
|
document.querySelectorAll('[data-potvrda]').forEach(function(el) {
|
||||||
if (el._potvrda) return;
|
if (el._potvrda) return;
|
||||||
el._potvrda = true;
|
el._potvrda = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user