Implement user login with password hash verification and username lookup
This commit is contained in:
@@ -61,15 +61,30 @@ func (appContext *AdminDashboardHandler) Register(c *gin.Context) {
|
||||
"success": false,
|
||||
"error": "failed to create user",
|
||||
})
|
||||
} else {
|
||||
c.JSON(200, gin.H{
|
||||
"success": true,
|
||||
})
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{
|
||||
"success": true,
|
||||
})
|
||||
}
|
||||
|
||||
func (appContext *AdminDashboardHandler) Login(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"YouAreOn": "Login",
|
||||
})
|
||||
|
||||
var input requestmodels.LoginInput
|
||||
|
||||
if err := c.ShouldBindJSON(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var user = appContext.AppContext.UserService.GetUserByUsername(input.Username)
|
||||
if auth.CheckPasswordHash(input.Password, user.Password) && user.IsVerified { // TODO: Add verification process
|
||||
c.JSON(200, gin.H{
|
||||
"success": true,
|
||||
})
|
||||
} else {
|
||||
c.JSON(200, gin.H{
|
||||
"success": false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user