TOTP methods can now be created on the frontend!
This commit is contained in:
parent
e457e979ff
commit
50cbce92fc
11 changed files with 295 additions and 56 deletions
|
@ -93,8 +93,6 @@ func AdminIndexHandler(app *model.AppState) http.Handler {
|
|||
func registerAccountHandler(app *model.AppState) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
session := r.Context().Value("session").(*model.Session)
|
||||
controller.SetSessionError(app.DB, session, "")
|
||||
controller.SetSessionMessage(app.DB, session, "")
|
||||
|
||||
if session.Account != nil {
|
||||
// user is already logged in
|
||||
|
@ -126,8 +124,7 @@ func registerAccountHandler(app *model.AppState) http.Handler {
|
|||
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
controller.SetSessionError(app.DB, session, "Malformed data.")
|
||||
render()
|
||||
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -201,6 +198,8 @@ func registerAccountHandler(app *model.AppState) http.Handler {
|
|||
|
||||
// registration success!
|
||||
controller.SetSessionAccount(app.DB, session, &account)
|
||||
controller.SetSessionMessage(app.DB, session, "")
|
||||
controller.SetSessionError(app.DB, session, "")
|
||||
http.Redirect(w, r, "/admin", http.StatusFound)
|
||||
})
|
||||
}
|
||||
|
@ -240,8 +239,7 @@ func loginHandler(app *model.AppState) http.Handler {
|
|||
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
controller.SetSessionError(app.DB, session, "Malformed data.")
|
||||
render()
|
||||
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -309,6 +307,8 @@ func loginHandler(app *model.AppState) http.Handler {
|
|||
|
||||
// login success!
|
||||
controller.SetSessionAccount(app.DB, session, account)
|
||||
controller.SetSessionMessage(app.DB, session, "")
|
||||
controller.SetSessionError(app.DB, session, "")
|
||||
http.Redirect(w, r, "/admin", http.StatusFound)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue