Actually compare to users in database
This commit is contained in:
10
http/http.go
10
http/http.go
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user