/**
* Try to reset the password
+ * @param \User $user
* @param AuthenticationRequest[] $reqs
* @return AuthenticationResponse
*/
}
}
- 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(
$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 );