mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
Store token data on passkey auth
This commit is contained in:
parent
ae170acb30
commit
7e48953b6a
@ -374,6 +374,12 @@ func (h *UserHandler) FinishPasskeyAuthenticationCeremony(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
err = h.UserController.PasskeyRepo.StoreTokenData(request.SessionID, response)
|
||||
if err != nil {
|
||||
handler.Error(c, stacktrace.Propagate(err, "failed to store token data"))
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
|
@ -167,6 +167,16 @@ func (r *Repository) GetUserIDWithPasskeyTwoFactorSession(sessionID string) (use
|
||||
return
|
||||
}
|
||||
|
||||
// StoreTokenData takes a sessionID, and tokenData, and updates the tokenData in the database
|
||||
func (r *Repository) StoreTokenData(sessionID string, tokenData ente.TwoFactorAuthorizationResponse) error {
|
||||
tokenDataJson, err := json.Marshal(tokenData)
|
||||
if err != nil {
|
||||
return stacktrace.Propagate(err, "")
|
||||
}
|
||||
_, err = r.DB.Exec(`UPDATE passkey_login_sessions SET token_data = $1, verified_at = now_utc_micro_seconds() WHERE session_id = $2`, tokenDataJson, sessionID)
|
||||
return stacktrace.Propagate(err, "")
|
||||
}
|
||||
|
||||
func (r *Repository) CreateBeginAuthenticationData(user *ente.User) (options *protocol.CredentialAssertion, session *webauthn.SessionData, id uuid.UUID, err error) {
|
||||
passkeyUser := &PasskeyUser{
|
||||
User: user,
|
||||
|
Loading…
x
Reference in New Issue
Block a user