Actually compare to users in database

This commit is contained in:
jacob1123 committed 2016-12-20 13:36:30 +01:00
1 parent 7b235f83ad
commit e955638510
3 files changed
+22 -2

No files matched your search

+8 -2
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)
}