fix: use printf
This commit is contained in:
@ -66,14 +66,14 @@ func (h *AuthHandler) login(w http.ResponseWriter, r *http.Request) {
|
|||||||
deviceInfo.UserAgent = userAgent
|
deviceInfo.UserAgent = userAgent
|
||||||
|
|
||||||
if location, err := util.GetLocation(r.RemoteAddr); err != nil {
|
if location, err := util.GetLocation(r.RemoteAddr); err != nil {
|
||||||
log.Println("WARN: Failed to get location from ip (%s): %v\n", r.RemoteAddr, err)
|
log.Printf("WARN: Failed to get location from ip (%s): %v\n", r.RemoteAddr, err)
|
||||||
} else {
|
} else {
|
||||||
deviceInfo.Location = fmt.Sprintf("%s, %s, %s", location.Country, location.Region, location.City)
|
deviceInfo.Location = fmt.Sprintf("%s, %s, %s", location.Country, location.Region, location.City)
|
||||||
}
|
}
|
||||||
|
|
||||||
serialized, err := json.Marshal(deviceInfo)
|
serialized, err := json.Marshal(deviceInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("ERR: Failed to serialize device info: %v\n", err)
|
log.Printf("ERR: Failed to serialize device info: %v\n", err)
|
||||||
serialized = []byte{'{', '}'}
|
serialized = []byte{'{', '}'}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,10 +90,10 @@ func (h *AuthHandler) login(w http.ResponseWriter, r *http.Request) {
|
|||||||
DeviceInfo: serialized,
|
DeviceInfo: serialized,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("ERR: Failedd to create user session after logging in: %v\n", err)
|
log.Printf("ERR: Failedd to create user session after logging in: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("INFO: User session created for '%s': %#v\n", user.Email, session)
|
log.Printf("INFO: User session created for '%s': %#v\n", user.Email, session)
|
||||||
|
|
||||||
if err := h.repo.UpdateLastLogin(r.Context(), user.ID); err != nil {
|
if err := h.repo.UpdateLastLogin(r.Context(), user.ID); err != nil {
|
||||||
web.Error(w, "failed to update user's last login", http.StatusInternalServerError)
|
web.Error(w, "failed to update user's last login", http.StatusInternalServerError)
|
||||||
|
Reference in New Issue
Block a user