Skip to content

Commit

Permalink
feat: add friendly name to enroll factor response (supabase#1277)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?

See title
 - [x] Need to update docs
 

PR to update GoTrue: https://github.com/supabase/gotrue/pull/1277/files
Docs Update: supabase#1277

---------

Co-authored-by: [email protected] <[email protected]>
  • Loading branch information
J0 and [email protected] authored Nov 15, 2023
1 parent 86b4310 commit 0c6eb61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/api/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ type TOTPObject struct {
}

type EnrollFactorResponse struct {
ID uuid.UUID `json:"id"`
Type string `json:"type"`
TOTP TOTPObject `json:"totp,omitempty"`
ID uuid.UUID `json:"id"`
Type string `json:"type"`
FriendlyName string `json:"friendly_name"`
TOTP TOTPObject `json:"totp,omitempty"`
}

type VerifyFactorParams struct {
Expand Down Expand Up @@ -149,8 +150,9 @@ func (a *API) EnrollFactor(w http.ResponseWriter, r *http.Request) error {
}

return sendJSON(w, http.StatusOK, &EnrollFactorResponse{
ID: factor.ID,
Type: models.TOTP,
ID: factor.ID,
Type: models.TOTP,
FriendlyName: factor.FriendlyName,
TOTP: TOTPObject{
// See: https://css-tricks.com/probably-dont-base64-svg/
QRCode: buf.String(),
Expand Down
1 change: 1 addition & 0 deletions internal/api/mfa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (ts *MFATestSuite) TestEnrollFactor() {
qrCode := enrollResp.TOTP.QRCode
hasSVGStartAndEnd := strings.Contains(qrCode, "<svg") && strings.Contains(qrCode, "</svg>")
require.True(ts.T(), hasSVGStartAndEnd)
require.Equal(ts.T(), c.friendlyName, enrollResp.FriendlyName)
}
})
}
Expand Down

0 comments on commit 0c6eb61

Please sign in to comment.