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