fix #193 - auth middleware bug

This commit is contained in:
Matej Kramny 2016-12-21 17:42:01 +09:00
parent 411f612b85
commit 324b6c9ee0

View File

@ -15,7 +15,7 @@ import (
func authentication(c *gin.Context) { func authentication(c *gin.Context) {
var userID int var userID int
if authHeader := strings.ToLower(c.Request.Header.Get("authorization")); len(authHeader) > 0 { if authHeader := strings.ToLower(c.Request.Header.Get("authorization")); len(authHeader) > 0 && strings.Contains(authHeader, "bearer") {
var token models.APIToken var token models.APIToken
if err := database.Mysql.SelectOne(&token, "select * from user__token where id=? and expired=0", strings.Replace(authHeader, "bearer ", "", 1)); err != nil { if err := database.Mysql.SelectOne(&token, "select * from user__token where id=? and expired=0", strings.Replace(authHeader, "bearer ", "", 1)); err != nil {
if err == sql.ErrNoRows { if err == sql.ErrNoRows {