Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / auth / ResetPasswordSecondaryAuthenticationProvider.php
index 2e51cf2..45ac3aa 100644 (file)
@@ -58,6 +58,7 @@ class ResetPasswordSecondaryAuthenticationProvider extends AbstractSecondaryAuth
 
        /**
         * Try to reset the password
+        * @param \User $user
         * @param AuthenticationRequest[] $reqs
         * @return AuthenticationResponse
         */
@@ -95,12 +96,12 @@ class ResetPasswordSecondaryAuthenticationProvider extends AbstractSecondaryAuth
                        }
                }
 
-               if ( isset( $data->req ) ) {
-                       $needReq = $data->req;
-               } else {
-                       $needReq = new PasswordAuthenticationRequest();
+               $needReq = isset( $data->req ) ? $data->req : new PasswordAuthenticationRequest();
+               if ( !$needReq->action ) {
                        $needReq->action = AuthManager::ACTION_CHANGE;
                }
+               $needReq->required = $data->hard ? AuthenticationRequest::REQUIRED
+                       : AuthenticationRequest::OPTIONAL;
                $needReqs = [ $needReq ];
                if ( !$data->hard ) {
                        $needReqs[] = new ButtonAuthenticationRequest(
@@ -112,17 +113,17 @@ class ResetPasswordSecondaryAuthenticationProvider extends AbstractSecondaryAuth
 
                $req = AuthenticationRequest::getRequestByClass( $reqs, get_class( $needReq ) );
                if ( !$req || !array_key_exists( 'retype', $req->getFieldInfo() ) ) {
-                       return AuthenticationResponse::newUI( $needReqs, $data->msg );
+                       return AuthenticationResponse::newUI( $needReqs, $data->msg, 'warning' );
                }
 
                if ( $req->password !== $req->retype ) {
-                       return AuthenticationResponse::newUI( $needReqs, new \Message( 'badretype' ) );
+                       return AuthenticationResponse::newUI( $needReqs, new \Message( 'badretype' ), 'error' );
                }
 
                $req->username = $user->getName();
                $status = $this->manager->allowsAuthenticationDataChange( $req );
                if ( !$status->isGood() ) {
-                       return AuthenticationResponse::newUI( $needReqs, $status->getMessage() );
+                       return AuthenticationResponse::newUI( $needReqs, $status->getMessage(), 'error' );
                }
                $this->manager->changeAuthenticationData( $req );