mirror of
https://github.com/ente-io/ente.git
synced 2025-08-14 02:07:33 +00:00
[server][delete] return list of apps being used
This commit is contained in:
@@ -115,6 +115,7 @@ type DeleteChallengeResponse struct {
|
|||||||
// AllowDelete indicates whether the user is allowed to delete their account via app
|
// AllowDelete indicates whether the user is allowed to delete their account via app
|
||||||
AllowDelete bool `json:"allowDelete"`
|
AllowDelete bool `json:"allowDelete"`
|
||||||
EncryptedChallenge *string `json:"encryptedChallenge,omitempty"`
|
EncryptedChallenge *string `json:"encryptedChallenge,omitempty"`
|
||||||
|
Apps []App `json:"apps"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteAccountRequest struct {
|
type DeleteAccountRequest struct {
|
||||||
|
@@ -49,9 +49,15 @@ func (c *UserController) GetDeleteChallengeToken(ctx *gin.Context) (*ente.Delete
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, stacktrace.Propagate(err, "")
|
return nil, stacktrace.Propagate(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apps, err := c.UserAuthRepo.GetAppsForUser(userID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, stacktrace.Propagate(err, "")
|
||||||
|
}
|
||||||
return &ente.DeleteChallengeResponse{
|
return &ente.DeleteChallengeResponse{
|
||||||
EncryptedChallenge: &encryptedToken,
|
EncryptedChallenge: &encryptedToken,
|
||||||
AllowDelete: true,
|
AllowDelete: true,
|
||||||
|
Apps: apps,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,6 +66,24 @@ func (repo *UserAuthRepository) GetUserTokenInfo(userID int64) ([]ente.TokenInfo
|
|||||||
return tokenInfos, nil
|
return tokenInfos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *UserAuthRepository) GetAppsForUser(userID int64) ([]ente.App, error) {
|
||||||
|
rows, err := repo.DB.Query(`SELECT DISTINCT app FROM tokens WHERE user_id = $1`, userID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, stacktrace.Propagate(err, "")
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
apps := make([]ente.App, 0)
|
||||||
|
for rows.Next() {
|
||||||
|
var app ente.App
|
||||||
|
err := rows.Scan(&app)
|
||||||
|
if err != nil {
|
||||||
|
return nil, stacktrace.Propagate(err, "")
|
||||||
|
}
|
||||||
|
apps = append(apps, app)
|
||||||
|
}
|
||||||
|
return apps, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetValidOTTs returns the list of OTTs that haven't expired for a given user
|
// GetValidOTTs returns the list of OTTs that haven't expired for a given user
|
||||||
func (repo *UserAuthRepository) GetValidOTTs(emailHash string, app ente.App) ([]string, error) {
|
func (repo *UserAuthRepository) GetValidOTTs(emailHash string, app ente.App) ([]string, error) {
|
||||||
rows, err := repo.DB.Query(`SELECT ott FROM otts WHERE email_hash = $1 AND app = $2 AND expiration_time > $3`,
|
rows, err := repo.DB.Query(`SELECT ott FROM otts WHERE email_hash = $1 AND app = $2 AND expiration_time > $3`,
|
||||||
|
Reference in New Issue
Block a user