Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[server] Return accounts & familyUrl

Neeraj Gupta4cb11f4b06d8
diff --git a/server/ente/user.go b/server/ente/user.go
index 59925e90c1..554f7fdcab 100644
--- a/server/ente/user.go
+++ b/server/ente/user.go
@@ -49,12 +49,14 @@ type EmailVerificationResponse struct {
// EmailAuthorizationResponse represents the response after user has verified his email,
// if two factor enabled just `TwoFactorSessionID` is sent else the keyAttributes and encryptedToken
type EmailAuthorizationResponse struct {
- ID int64 `json:"id"`
- KeyAttributes *KeyAttributes `json:"keyAttributes,omitempty"`
- EncryptedToken string `json:"encryptedToken,omitempty"`
- Token string `json:"token,omitempty"`
- PasskeySessionID string `json:"passkeySessionID"`
- TwoFactorSessionID string `json:"twoFactorSessionID"`
+ ID int64 `json:"id"`
+ KeyAttributes *KeyAttributes `json:"keyAttributes,omitempty"`
+ EncryptedToken string `json:"encryptedToken,omitempty"`
+ Token string `json:"token,omitempty"`
+ PasskeySessionID string `json:"passkeySessionID"`
+ // AccountUrl is the url used for passkey validation
+ AccountUrl string `json:"accountUrl"`
+ TwoFactorSessionID string `json:"twoFactorSessionID"`
// TwoFactorSessionIDV2 is set only if user has both passkey and two factor enabled.
// This is to ensure older clients keep using passkey flow when both are set. We can remove
// This field once the clients starts surface both options for performing 2fa
diff --git a/server/pkg/api/user.go b/server/pkg/api/user.go
index 930ea6ec8c..481c954273 100644
--- a/server/pkg/api/user.go
+++ b/server/pkg/api/user.go
@@ -7,6 +7,7 @@ import (
"github.com/ente-io/museum/pkg/controller/emergency"
"github.com/gin-contrib/requestid"
"github.com/sirupsen/logrus"
+ "github.com/spf13/viper"
"net/http"
"strconv"
"strings"
@@ -473,6 +474,7 @@ func (h *UserHandler) GetFamiliesToken(c *gin.Context) {
}
c.JSON(http.StatusOK, gin.H{
"familiesToken": token,
+ "familyUrl": viper.GetString("apps.family"),
})
}
@@ -485,6 +487,7 @@ func (h *UserHandler) GetAccountsToken(c *gin.Context) {
}
c.JSON(http.StatusOK, gin.H{
"accountsToken": token,
+ "accountUrl": viper.GetString("apps.account"),
})
}
diff --git a/server/pkg/controller/user/userauth.go b/server/pkg/controller/user/userauth.go
index e4789a0e18..bccc15d396 100644
--- a/server/pkg/controller/user/userauth.go
+++ b/server/pkg/controller/user/userauth.go
@@ -405,10 +405,11 @@ func (c *UserController) onVerificationSuccess(context *gin.Context, email strin
return ente.EmailAuthorizationResponse{}, stacktrace.Propagate(err, "")
}
}
+ accountUrl := viper.GetString("apps.accounts")
if hasPasskeys && isTwoFactorEnabled {
- return ente.EmailAuthorizationResponse{ID: userID, PasskeySessionID: passKeySessionID, TwoFactorSessionIDV2: twoFactorSessionID}, nil
+ return ente.EmailAuthorizationResponse{ID: userID, PasskeySessionID: passKeySessionID, AccountUrl: accountUrl, TwoFactorSessionIDV2: twoFactorSessionID}, nil
} else if hasPasskeys {
- return ente.EmailAuthorizationResponse{ID: userID, PasskeySessionID: passKeySessionID}, nil
+ return ente.EmailAuthorizationResponse{ID: userID, PasskeySessionID: passKeySessionID, AccountUrl: accountUrl}, nil
} else if isTwoFactorEnabled {
return ente.EmailAuthorizationResponse{ID: userID, TwoFactorSessionID: twoFactorSessionID}, nil
}