Fix server status

This commit is contained in:
Neeraj Gupta
2024-12-10 11:45:24 +05:30
parent 8db40c5c58
commit 7952257a89
2 changed files with 15 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/ente-io/stacktrace"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)
func (c *Controller) GetRecoveryInfo(ctx *gin.Context,
@@ -50,6 +51,16 @@ func (c *Controller) ChangePassword(ctx *gin.Context, userID int64, request ente
if err != nil {
return nil, stacktrace.Propagate(err, "")
}
hasUpdate, err := c.Repo.UpdateRecoveryStatusForID(ctx, sessionID, ente.RecoveryStatusRecovered)
if err != nil {
return nil, stacktrace.Propagate(err, "failed to update recovery status")
}
if !hasUpdate {
log.WithField("userID", userID).WithField("req", request).
Warn("no row updated while rejecting recovery")
}
return resp, nil
}

View File

@@ -8,13 +8,13 @@ import (
)
func (c *Controller) StartRecovery(ctx *gin.Context,
userID int64,
actorUserID int64,
req ente.ContactIdentifier) error {
if req.EmergencyContactID == req.UserID {
return stacktrace.Propagate(ente.NewBadRequestWithMessage("contact and user can not be same"), "")
}
if req.EmergencyContactID != userID {
return stacktrace.Propagate(ente.ErrPermissionDenied, "user can only update his own state")
if req.EmergencyContactID != actorUserID {
return stacktrace.Propagate(ente.ErrPermissionDenied, "only the emergency contact can start recovery")
}
contact, err := c.Repo.GetActiveEmergencyContact(ctx, req.UserID, req.EmergencyContactID)
@@ -24,7 +24,7 @@ func (c *Controller) StartRecovery(ctx *gin.Context,
hasUpdate, err := c.Repo.InsertIntoRecovery(ctx, req, *contact)
if !hasUpdate {
log.WithField("userID", userID).WithField("req", req).
log.WithField("userID", actorUserID).WithField("req", req).
Warn("No need to send email")
}
if err != nil {