mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-03-09 18:29:12 -04:00
Streamline passkey display name creation (#520)
This commit is contained in:
@@ -34,7 +34,7 @@ const PasskeyCreate: React.FC = () => {
|
||||
const webApi = useWebApi();
|
||||
const { executeVaultMutation, isLoading: isMutating, syncStatus } = useVaultMutate();
|
||||
const [request, setRequest] = useState<PendingPasskeyCreateRequest | null>(null);
|
||||
const [displayName, setDisplayName] = useState('My Passkey');
|
||||
const [displayName, setDisplayName] = useState('');
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const { isLocked } = useVaultLockRedirect();
|
||||
const [existingPasskeys, setExistingPasskeys] = useState<Array<Passkey & { Username?: string | null; ServiceName?: string | null }>>([]);
|
||||
@@ -71,9 +71,12 @@ const PasskeyCreate: React.FC = () => {
|
||||
if (data && data.type === 'create') {
|
||||
setRequest(data);
|
||||
|
||||
if (data.publicKey?.user?.displayName) {
|
||||
setDisplayName(data.publicKey.user.displayName);
|
||||
}
|
||||
/**
|
||||
* Set default displayName: use rp.name if available, otherwise use rpId
|
||||
* This aligns with iOS/Android behavior
|
||||
*/
|
||||
const defaultName = data.publicKey?.rp?.name || data.publicKey?.rp?.id || 'Passkey';
|
||||
setDisplayName(defaultName);
|
||||
|
||||
// Check for existing passkeys for this RP ID and user
|
||||
if (dbContext.sqliteClient && data.publicKey?.rp?.id) {
|
||||
|
||||
@@ -130,7 +130,7 @@ class PasskeyFormFragment : Fragment() {
|
||||
headerTitle.text = getString(R.string.create_passkey_title)
|
||||
headerSubtitle.visibility = View.GONE
|
||||
infoExplanationText.text = getString(R.string.passkey_create_explanation)
|
||||
displayNameInput.setText(viewModel.rpId)
|
||||
displayNameInput.setText(viewModel.rpName ?: viewModel.rpId)
|
||||
saveButton.text = getString(R.string.passkey_create_button)
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ class PasskeyRegistrationActivity : FragmentActivity() {
|
||||
// Extract RP info
|
||||
val rpObj = requestObj.optJSONObject("rp")
|
||||
viewModel.rpId = rpObj?.optString("id") ?: ""
|
||||
viewModel.rpName = rpObj?.optString("name")?.takeIf { it.isNotEmpty() }
|
||||
|
||||
// Extract user info
|
||||
val userObj = requestObj.optJSONObject("user")
|
||||
|
||||
@@ -20,6 +20,9 @@ class PasskeyRegistrationViewModel : ViewModel() {
|
||||
/** The relying party identifier. */
|
||||
var rpId: String = ""
|
||||
|
||||
/** The relying party name (optional, from rp.name in the request). */
|
||||
var rpName: String? = null
|
||||
|
||||
/** The username for the passkey. */
|
||||
var userName: String? = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user