Make sure key is of correct type before running operations on it

Bug: T231786
Change-Id: I54aad0753fa3eda48e7f382b27b1c89069f40d36
This commit is contained in:
Dejan Savuljesku 2019-09-04 13:15:17 +02:00 committed by Reedy
parent 484241edf0
commit ae53dc5c60

View file

@ -5,10 +5,11 @@ namespace MediaWiki\Extension\OATHAuth\HTMLForm;
use MediaWiki\Extension\OATHAuth\Key\TOTPKey;
use MediaWiki\Logger\LoggerFactory;
use Html;
use Status;
class TOTPEnableForm extends OATHAuthOOUIHTMLForm implements IManageForm {
/**
* @param array|bool|\Status|string $submitResult
* @param array|bool|Status|string $submitResult
* @return string
*/
public function getHTML( $submitResult ) {
@ -28,7 +29,7 @@ class TOTPEnableForm extends OATHAuthOOUIHTMLForm implements IManageForm {
protected function getDescriptors() {
$key = $this->getRequest()->getSessionData( 'oathauth_totp_key' );
if ( $key === null ) {
if ( !$key instanceof TOTPKey ) {
$key = TOTPKey::newFromRandom();
$this->getRequest()->setSessionData( 'oathauth_totp_key', $key );
}