Actually compare to users in database

This commit is contained in:
2016-12-20 13:36:30 +01:00
parent 7b235f83ad
commit e955638510
3 changed files with 22 additions and 2 deletions

View File

@ -107,12 +107,18 @@ func (h *Handler) loginPost(c *gin.Context) {
username, _ := c.GetPostForm("username")
password, _ := c.GetPostForm("password")
if username != "jan" || password != "passwort" {
user, err := h.UserService.UserByUsername(username)
if err != nil {
c.AbortWithStatus(http.StatusUnauthorized)
return
}
t, err := h.TokenVerifier.CreateToken(username, "Jan Bader")
if password != user.Password {
c.AbortWithStatus(http.StatusUnauthorized)
return
}
t, err := h.TokenVerifier.CreateToken(user.Email, user.Name)
if err != nil {
c.AbortWithStatus(http.StatusUnauthorized)
}