mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-02-02 11:39:19 +01:00
Fix #110 - Reset WebAuthn user options after last device revocation
This commit is contained in:
parent
caf72a6c9f
commit
fbb85342c1
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Facades\Settings;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\WebauthnRenameRequest;
|
||||
@ -72,6 +73,13 @@ public function delete(Request $request, $credential)
|
||||
$user = $request->user();
|
||||
$user->removeCredential($credential);
|
||||
|
||||
// Webauthn user options should be reset to prevent impossible login
|
||||
// See #110
|
||||
if (blank($user->allCredentialDescriptors())) {
|
||||
Settings::delete('useWebauthnAsDefault');
|
||||
Settings::delete('useWebauthnOnly');
|
||||
}
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
@ -75,7 +75,7 @@
|
||||
},
|
||||
|
||||
async mounted() {
|
||||
|
||||
|
||||
const { data } = await this.form.get('/api/v1/settings')
|
||||
|
||||
this.form.fillWithKeyValueObject(data)
|
||||
@ -180,6 +180,14 @@
|
||||
await this.axios.delete('/webauthn/credentials/' + credentialId).then(response => {
|
||||
// Remove the revoked credential from the collection
|
||||
this.credentials = this.credentials.filter(a => a.id !== credentialId)
|
||||
|
||||
if (this.credentials.length == 0) {
|
||||
this.form.useWebauthnOnly = false
|
||||
this.form.useWebauthnAsDefault = false
|
||||
this.$root.appSettings['useWebauthnOnly'] = false
|
||||
this.$root.appSettings['useWebauthnAsDefault'] = false
|
||||
}
|
||||
|
||||
this.$notify({ type: 'is-success', text: this.$t('auth.webauthn.device_revoked') })
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user