This commit is contained in:
Nedim
2023-11-14 20:41:51 +01:00
parent 758e033870
commit f9328bdecb

View File

@@ -130,12 +130,12 @@ func Login(c *gin.Context) {
if usr.CheckPassword(user.Password, req.Password) { if usr.CheckPassword(user.Password, req.Password) {
if user.IsActive && user.LoginAttempts < 10 { if user.IsActive && user.LoginAttempts < 10 {
// Proceed with creating JWT token and resetting login attempts // Proceed with creating JWT token and resetting login attempts
if len(user.Companies) == 0 { // if len(user.Companies) == 0 {
c.JSON(http.StatusInternalServerError, gin.H{"error": "User is not connected to a company"}) // c.JSON(http.StatusInternalServerError, gin.H{"error": "User is not connected to a company"})
return // return
} // }
token, err := usr.CreateSessionToken(user.ID, user.Companies[0].ID) token, err := usr.CreateSessionToken(user.ID, 2)
if err != nil { if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Could not create JWT token"}) c.JSON(http.StatusInternalServerError, gin.H{"error": "Could not create JWT token"})
return return