More middleware unit tests cover all current auth mechanisms

This commit is contained in:
Torkel Ödegaard
2015-05-02 09:24:56 +02:00
parent f416e2d1ac
commit ba883d25fe
3 changed files with 181 additions and 77 deletions

View File

@ -1,6 +1,7 @@
package middleware
import (
"fmt"
"strconv"
"strings"
@ -78,11 +79,13 @@ func initContextWithUserSessionCookie(ctx *Context) bool {
var userId int64
if userId = getRequestUserId(ctx); userId == 0 {
fmt.Printf("Not userId")
return false
}
query := m.GetSignedInUserQuery{UserId: userId}
if err := bus.Dispatch(&query); err != nil {
log.Error(3, "Failed to get user with id %v", userId)
return false
} else {
ctx.SignedInUser = query.Result