Add models passkey reset via recoveryKey
This commit is contained in:
parent
23fcce245d
commit
13bae268ec
2 changed files with 51 additions and 0 deletions
28
server/ente/enc_data.go
Normal file
28
server/ente/enc_data.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package ente
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// EncData is a struct that holds an encrypted data and related nonce.
|
||||
type EncData struct {
|
||||
Data string `json:"data"`
|
||||
Nonce string `json:"nonce"`
|
||||
}
|
||||
|
||||
// Value implements the driver.Valuer interface, allowing EncString to be used as a SQL value.
|
||||
func (e EncData) Value() (driver.Value, error) {
|
||||
return json.Marshal(e)
|
||||
}
|
||||
|
||||
// Scan implements the sql.Scanner interface, allowing EncString to be scanned from SQL queries.
|
||||
func (e *EncData) Scan(value interface{}) error {
|
||||
// Convert to bytes if necessary (depends on the driver, pq returns []byte for JSONB)
|
||||
b, ok := value.([]byte)
|
||||
if !ok {
|
||||
return fmt.Errorf("type assertion to []byte failed")
|
||||
}
|
||||
return json.Unmarshal(b, &e)
|
||||
}
|
|
@ -12,3 +12,26 @@ type Passkey struct {
|
|||
}
|
||||
|
||||
var MaxPasskeys = 10
|
||||
|
||||
type EnablePassKeyRecovery struct {
|
||||
UserID int64 `json:"userID" binding:"required"`
|
||||
ResetKey string `json:"resetKey" binding:"required"`
|
||||
EncResetKey EncData `json:"encResetKey" binding:"required"`
|
||||
}
|
||||
|
||||
type AccountRecoveryStatus struct {
|
||||
// AllowAdminReset is a boolean that determines if the admin can reset the user's MFA.
|
||||
// If true, in the event that the user loses their MFA device, the admin can reset the user's MFA.
|
||||
AllowAdminReset bool `json:"allowAdminReset" binding:"required"`
|
||||
IsPassKeyResetEnabled bool `json:"isPassKeyResetEnabled" binding:"required"`
|
||||
}
|
||||
|
||||
type PasseKeyResetChallengeResponse struct {
|
||||
EncResetKey string `json:"encResetKey" binding:"required"`
|
||||
EncResetKeyNonce string `json:"encResetKeyNonce" binding:"required"`
|
||||
}
|
||||
|
||||
type ResetPassKey struct {
|
||||
SessionID string `json:"sessionID" binding:"required"`
|
||||
RestKey string `json:"resetKey" binding:"required"`
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue