Skip to content

Commit

Permalink
[cli] Fix login for auth app when passkey is enabled (#3815)
Browse files Browse the repository at this point in the history
## Description

## Tests
  • Loading branch information
ua741 authored Oct 23, 2024
2 parents 0c16291 + 819c0bc commit 3b17d49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/pkg/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *ClICtrl) AddAccount(cxt context.Context) {
}

if authResponse.IsPasskeyRequired() {
authResponse, flowErr = c.verifyPassKey(cxt, authResponse)
authResponse, flowErr = c.verifyPassKey(cxt, authResponse, app)
}
if authResponse.EncryptedToken == "" || authResponse.KeyAttributes == nil {
log.Fatalf("missing key attributes or token.\nNote: Please use the mobile,web or desktop app to create a new account.\nIf you are trying to login to an existing account, report a bug.")
Expand Down
4 changes: 2 additions & 2 deletions cli/pkg/sign_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ func (c *ClICtrl) validateTOTP(ctx context.Context, authResp *api.AuthorizationR
}
}

func (c *ClICtrl) verifyPassKey(ctx context.Context, authResp *api.AuthorizationResponse) (*api.AuthorizationResponse, error) {
func (c *ClICtrl) verifyPassKey(ctx context.Context, authResp *api.AuthorizationResponse, app api.App) (*api.AuthorizationResponse, error) {
if !authResp.IsPasskeyRequired() {
return authResp, nil
}
baseAccountUrl := viper.GetString("endpoint.accounts")
passkeyAuthUrl := fmt.Sprintf("%s/passkeys/verify?passkeySessionID=%s&redirect=ente-cli://passkey&clientPackage=io.ente.photos", baseAccountUrl, authResp.PassKeySessionID)
passkeyAuthUrl := fmt.Sprintf("%s/passkeys/verify?passkeySessionID=%s&redirect=ente-cli://passkey&clientPackage=%s", baseAccountUrl, authResp.PassKeySessionID, app.ClientPkg())
fmt.Printf("Open this url in browser to verify passkey: %s\n", passkeyAuthUrl)
err := browser.OpenURL(passkeyAuthUrl)
if err != nil {
Expand Down

0 comments on commit 3b17d49

Please sign in to comment.