-
Notifications
You must be signed in to change notification settings - Fork 2
/
recover_get.go
34 lines (32 loc) · 875 Bytes
/
recover_get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package basicserver
import (
"github.com/kataras/iris"
)
// ServeRecoverPasswordGet serves
// Method: GET
// Resource: http://localhost/recover/{code:string}
//
// This should return status code `200` and response body with html form.
//
func (app *BasicApp) ServeRecoverPasswordGet(v string) iris.Handler {
return func(ctx iris.Context) {
switch v {
case "":
ctx.HTML(`
<form method="POST">
<input name="email" type="text" placeholder="Email" />
<button type="submit">Send</button>
</form>`)
case "code":
recCode := ctx.Params().Get("code")
ctx.HTML(`
<form action="/change" method="POST">
<input name="password" type="text" placeholder="Password" />
<input name="code" type="hidden" value="` + recCode + `" />
<button type="submit">Send</button>
</form>`)
case "done":
ctx.WriteString(`Password Changed!`)
}
}
}