Explorar el Código

Fixed #10: Cookie & Param token für login

Moritz Schmidt hace 9 años
padre
commit
2536e9991a
Se han modificado 2 ficheros con 2 adiciones y 1 borrados
  1. 1 0
      main.go
  2. 1 1
      templates/login_box.html

+ 1 - 0
main.go

@@ -74,6 +74,7 @@ func loginHandler(ctx *iris.Context) { // TODO outsource?
   user := usermanager.User{} // new user
   tokenString, err := user.Login(username, password) // try to login
   ctx.SetCookieKV("token", tokenString)
+  ctx.Set("token", tokenString) // set tokenstring as ctx-param as cookie can't be read in next context(s)
 
   if err != nil {
     errorhelpers.HandleError(err, ctx)

+ 1 - 1
templates/login_box.html

@@ -1,6 +1,6 @@
 <form class="form-signin" action="/login" method="post">
   <!--<h2 class="form-signin-heading">ayy</h2>-->
-  <label for="input-username" class="sr-only">email address</label>
+  <label for="input-username" class="sr-only">username</label>
   <input type="text" id="input-username" name="username" class="form-control" placeholder="username" required autofocus>
   <label for="input-password" class="sr-only">password</label>
   <input type="password" id="input-password" name="password" class="form-control" placeholder="password" required>