mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-27 05:51:56 +00:00 
			
		
		
		
	Updated tests and views
This commit is contained in:
		| @@ -24,8 +24,11 @@ namespace FireflyIII\Http\Controllers\Auth; | |||||||
|  |  | ||||||
| use FireflyConfig; | use FireflyConfig; | ||||||
| use FireflyIII\Http\Controllers\Controller; | use FireflyIII\Http\Controllers\Controller; | ||||||
|  | use FireflyIII\Repositories\User\UserRepositoryInterface; | ||||||
| use FireflyIII\User; | use FireflyIII\User; | ||||||
| use Illuminate\Foundation\Auth\SendsPasswordResetEmails; | use Illuminate\Foundation\Auth\SendsPasswordResetEmails; | ||||||
|  | use Illuminate\Http\Request; | ||||||
|  | use Illuminate\Support\Facades\Password; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Class ForgotPasswordController |  * Class ForgotPasswordController | ||||||
| @@ -46,6 +49,50 @@ class ForgotPasswordController extends Controller | |||||||
|     use SendsPasswordResetEmails; |     use SendsPasswordResetEmails; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|  |      * Create a new controller instance. | ||||||
|  |      */ | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         parent::__construct(); | ||||||
|  |         $this->middleware('guest'); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Send a reset link to the given user. | ||||||
|  |      * | ||||||
|  |      * @param  \Illuminate\Http\Request $request | ||||||
|  |      * | ||||||
|  |      * @param UserRepositoryInterface   $repository | ||||||
|  |      * | ||||||
|  |      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse | ||||||
|  |      */ | ||||||
|  |     public function sendResetLinkEmail(Request $request, UserRepositoryInterface $repository) | ||||||
|  |     { | ||||||
|  |         $this->validateEmail($request); | ||||||
|  |  | ||||||
|  |         // verify if the user is not a demo user. If so, we give him back an error. | ||||||
|  |         $user = User::where('email', $request->get('email'))->first(); | ||||||
|  |  | ||||||
|  |         if (!is_null($user) && $repository->hasRole($user, 'demo')) { | ||||||
|  |             return back()->withErrors(['email' => trans('firefly.cannot_reset_demo_user')]); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         // We will send the password reset link to this user. Once we have attempted | ||||||
|  |         // to send the link, we will examine the response then see the message we | ||||||
|  |         // need to show to the user. Finally, we'll send out a proper response. | ||||||
|  |         $response = $this->broker()->sendResetLink( | ||||||
|  |             $request->only('email') | ||||||
|  |         ); | ||||||
|  |  | ||||||
|  |         if ($response == Password::RESET_LINK_SENT) { | ||||||
|  |             return back()->with('status', trans($response)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return back()->withErrors(['email' => trans($response)]); // @codeCoverageIgnore | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @codeCoverageIgnore | ||||||
|      * Display the form to request a password reset link. |      * Display the form to request a password reset link. | ||||||
|      * |      * | ||||||
|      * @return \Illuminate\Http\Response |      * @return \Illuminate\Http\Response | ||||||
| @@ -62,13 +109,4 @@ class ForgotPasswordController extends Controller | |||||||
|  |  | ||||||
|         return view('auth.passwords.email')->with(compact('allowRegistration')); |         return view('auth.passwords.email')->with(compact('allowRegistration')); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Create a new controller instance. |  | ||||||
|      */ |  | ||||||
|     public function __construct() |  | ||||||
|     { |  | ||||||
|         parent::__construct(); |  | ||||||
|         $this->middleware('guest'); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -108,6 +108,8 @@ class DebugController extends Controller | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|  |      * Some common combinations. | ||||||
|  |      * | ||||||
|      * @param int $value |      * @param int $value | ||||||
|      * |      * | ||||||
|      * @return string |      * @return string | ||||||
| @@ -116,12 +118,18 @@ class DebugController extends Controller | |||||||
|     { |     { | ||||||
|         $array = [ |         $array = [ | ||||||
|             -1                                                             => 'ALL errors', |             -1                                                             => 'ALL errors', | ||||||
|  |             E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED                  => 'E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED', | ||||||
|  |             E_ALL                                                          => 'E_ALL', | ||||||
|  |             E_ALL & ~E_DEPRECATED & ~E_STRICT                              => 'E_ALL & ~E_DEPRECATED & ~E_STRICT', | ||||||
|  |             E_ALL & ~E_NOTICE                                              => 'E_ALL & ~E_NOTICE', | ||||||
|  |             E_ALL & ~E_NOTICE & ~E_STRICT                                  => 'E_ALL & ~E_NOTICE & ~E_STRICT', | ||||||
|  |             E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR', | ||||||
|         ]; |         ]; | ||||||
|         if (isset($array[$value])) { |         if (isset($array[$value])) { | ||||||
|             return $array[$value]; |             return $array[$value]; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return strval($value); |         return strval($value); // @codeCoverageIgnore | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -103,7 +103,7 @@ return [ | |||||||
|     'file_map_field_mapped_to'        => 'Gelinkt aan', |     'file_map_field_mapped_to'        => 'Gelinkt aan', | ||||||
|     'map_do_not_map'                  => '(niet linken)', |     'map_do_not_map'                  => '(niet linken)', | ||||||
|     'file_map_submit'                 => 'Start importeren', |     'file_map_submit'                 => 'Start importeren', | ||||||
|     'file_nothing_to_map'             => 'There is no data present in your file that you can map to existing values. Please press "Start the import" to continue.', |     'file_nothing_to_map'             => 'Je gaat geen gegevens importeren die te mappen zijn. Klik op "Start import" om verder te gaan.', | ||||||
|  |  | ||||||
|     // map things. |     // map things. | ||||||
|     'column__ignore'                  => '(negeer deze kolom)', |     'column__ignore'                  => '(negeer deze kolom)', | ||||||
|   | |||||||
| @@ -103,7 +103,7 @@ return [ | |||||||
|     'file_map_field_mapped_to'        => 'Zmapowane do', |     'file_map_field_mapped_to'        => 'Zmapowane do', | ||||||
|     'map_do_not_map'                  => '(nie mapuj)', |     'map_do_not_map'                  => '(nie mapuj)', | ||||||
|     'file_map_submit'                 => 'Rozpocznij import', |     'file_map_submit'                 => 'Rozpocznij import', | ||||||
|     'file_nothing_to_map'             => 'There is no data present in your file that you can map to existing values. Please press "Start the import" to continue.', |     'file_nothing_to_map'             => 'W twoim pliku nie ma danych, które można by odwzorować na istniejące wartości. Naciśnij "Rozpocznij import", aby kontynuować.', | ||||||
|  |  | ||||||
|     // map things. |     // map things. | ||||||
|     'column__ignore'                  => '(zignoruj tę kolumnę)', |     'column__ignore'                  => '(zignoruj tę kolumnę)', | ||||||
|   | |||||||
| @@ -41,7 +41,7 @@ class ForgotPasswordControllerTest extends TestCase | |||||||
|     public function testSendResetLinkEmail() |     public function testSendResetLinkEmail() | ||||||
|     { |     { | ||||||
|         $repository = $this->mock(UserRepositoryInterface::class); |         $repository = $this->mock(UserRepositoryInterface::class); | ||||||
|         $repository->shouldReceive('hasRole')->andReturn(false); |         $repository->shouldReceive('hasRole')->andReturn(false)->once(); | ||||||
|         $data = [ |         $data = [ | ||||||
|             'email' => 'thegrumpydictator@gmail.com', |             'email' => 'thegrumpydictator@gmail.com', | ||||||
|         ]; |         ]; | ||||||
| @@ -57,7 +57,7 @@ class ForgotPasswordControllerTest extends TestCase | |||||||
|     public function testSendResetLinkEmailDemo() |     public function testSendResetLinkEmailDemo() | ||||||
|     { |     { | ||||||
|         $repository = $this->mock(UserRepositoryInterface::class); |         $repository = $this->mock(UserRepositoryInterface::class); | ||||||
|         $repository->shouldReceive('hasRole')->andReturn(true); |         $repository->shouldReceive('hasRole')->andReturn(true)->once(); | ||||||
|         $data = [ |         $data = [ | ||||||
|             'email' => 'thegrumpydictator@gmail.com', |             'email' => 'thegrumpydictator@gmail.com', | ||||||
|         ]; |         ]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user