Added the ability to remove an MFA method

Includes testing to cover
This commit is contained in:
Dan Brown
2021-07-14 21:27:21 +01:00
parent 7c86c26cd0
commit f696aa5eea
8 changed files with 75 additions and 0 deletions

View File

@ -2,6 +2,8 @@
namespace BookStack\Http\Controllers\Auth;
use BookStack\Actions\ActivityType;
use BookStack\Auth\Access\Mfa\MfaValue;
use BookStack\Http\Controllers\Controller;
class MfaController extends Controller
@ -18,4 +20,21 @@ class MfaController extends Controller
'userMethods' => $userMethods,
]);
}
/**
* Remove an MFA method for the current user.
* @throws \Exception
*/
public function remove(string $method)
{
if (in_array($method, MfaValue::allMethods())) {
$value = user()->mfaValues()->where('method', '=', $method)->first();
if ($value) {
$value->delete();
$this->logActivity(ActivityType::MFA_REMOVE_METHOD, $method);
}
}
return redirect('/mfa/setup');
}
}