mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +01:00
Fix key clash for username
This commit is contained in:
parent
efc3e1735b
commit
178c8ccce6
@ -35,10 +35,10 @@ func setupRoutes(router *mux.Router, routes []Route) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if user := auth.GetUser(r.Context()); user != nil {
|
if user := auth.GetUser(r.Context()); user != nil {
|
||||||
infos["username"] = user.Username
|
infos["loginId"] = user.Username
|
||||||
infos["admin"] = user.HasRole(auth.RoleAdmin)
|
infos["admin"] = user.HasRole(auth.RoleAdmin)
|
||||||
} else {
|
} else {
|
||||||
infos["username"] = false
|
infos["loginId"] = false
|
||||||
infos["admin"] = false
|
infos["admin"] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +133,7 @@ func setupJobRoute(i InfoType, r *http.Request) InfoType {
|
|||||||
|
|
||||||
func setupUserRoute(i InfoType, r *http.Request) InfoType {
|
func setupUserRoute(i InfoType, r *http.Request) InfoType {
|
||||||
i["id"] = mux.Vars(r)["id"]
|
i["id"] = mux.Vars(r)["id"]
|
||||||
|
i["username"] = mux.Vars(r)["id"]
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,10 +360,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if user := auth.GetUser(r.Context()); user != nil {
|
if user := auth.GetUser(r.Context()); user != nil {
|
||||||
infos["username"] = user.Username
|
infos["loginId"] = user.Username
|
||||||
infos["admin"] = user.HasRole(auth.RoleAdmin)
|
infos["admin"] = user.HasRole(auth.RoleAdmin)
|
||||||
} else {
|
} else {
|
||||||
infos["username"] = false
|
infos["loginId"] = false
|
||||||
infos["admin"] = false
|
infos["admin"] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,13 +69,13 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
{{if .Infos.username }}
|
{{if .Infos.loginId }}
|
||||||
<div class="d-flex align-items-end">
|
<div class="d-flex align-items-end">
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<form method="post" action="/logout">
|
<form method="post" action="/logout">
|
||||||
<button type="submit" class="btn btn-link nav-link fs-5">
|
<button type="submit" class="btn btn-link nav-link fs-5">
|
||||||
<span class="cc-nav-text">{{ .Infos.username }} Logout</span>
|
<span class="cc-nav-text">{{ .Infos.loginId }} Logout</span>
|
||||||
<i class="bi-box-arrow-right"></i>
|
<i class="bi-box-arrow-right"></i>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user