Handle id/alias mismatch, index
This commit is contained in:
parent
84d396cfb6
commit
4b86aadae4
|
@ -22,7 +22,7 @@ func index(w http.ResponseWriter, r *http.Request) {
|
|||
sCookie, err := r.Cookie("session")
|
||||
if err == nil && isAuthenticated(sCookie.Value) == nil {
|
||||
page.Title = "Miniwol"
|
||||
contentBuffer.WriteString("TODO")
|
||||
contentBuffer.WriteString("<a href='/device'>Device</a>")
|
||||
} else {
|
||||
page.Title = "Login"
|
||||
err = loginTemplate.Execute(&contentBuffer, struct{}{})
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
<th>IP/Broadcast</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
{{range .}}
|
||||
{{range $i, $d := .}}
|
||||
<tr>
|
||||
<td>{{.Alias}}</td>
|
||||
<td>{{.MAC}}</td>
|
||||
<td>{{.IP}}</td>
|
||||
<td>{{$d.Alias}}</td>
|
||||
<td>{{$d.MAC}}</td>
|
||||
<td>{{$d.IP}}</td>
|
||||
<td>
|
||||
<form action="/wake" method="post">
|
||||
<input type="text" name="alias" value="{{.Alias}}" hidden>
|
||||
<input type="text" name="index" value="{{$i}}" hidden>
|
||||
<input type="text" name="alias" value="{{$d.Alias}}" hidden>
|
||||
<input type="submit" value="Wake">
|
||||
</form>
|
||||
</td>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"miniwol/config"
|
||||
"miniwol/lib"
|
||||
"net/http"
|
||||
|
@ -12,8 +13,8 @@ func wake(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
for _, device := range config.Config.Device {
|
||||
if r.FormValue("alias") == device.Alias {
|
||||
for i, device := range config.Config.Device {
|
||||
if r.FormValue("alias") == device.Alias && r.FormValue("index") == fmt.Sprint(i) {
|
||||
if !strings.Contains(device.IP, ":") {
|
||||
device.IP += ":9"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user