change password
All checks were successful
Release / publish (push) Successful in 4m9s

This commit is contained in:
u80864958
2025-05-13 14:06:11 +02:00
parent 73ff28347a
commit 30dac9f12f
21 changed files with 288 additions and 16 deletions

View File

@ -48,6 +48,22 @@ func (s *Service) Signup(w http.ResponseWriter, r *http.Request) {
log.Printf("Error: %v", err)
w.WriteHeader(http.StatusInternalServerError)
}
token, err := s.createJWT(&user)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
res, err := json.Marshal(&LoginResponse{
Token: token,
})
if err != nil {
log.Println("Error: ", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Write(res)
}
// Signup handles user signup by decoding request body, hashing the password, and saving user data to the database.
@ -86,7 +102,7 @@ func (s *Service) ChangePassword(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
}
w.WriteHeader(http.StatusOK)
w.WriteHeader(http.StatusNoContent)
}
// Login handles user login by decoding request body, verifying credentials, and returning a JWT token.