From: Dan Brown Date: Sat, 12 Nov 2016 11:40:54 +0000 (+0000) Subject: Merge fixes from branch 'v0.12' X-Git-Tag: v0.13.0~1^2~7 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/ac80723058ab4c86e6bf024e0c75b60ab6c59624?hp=-c Merge fixes from branch 'v0.12' --- ac80723058ab4c86e6bf024e0c75b60ab6c59624 diff --combined app/Http/Controllers/Auth/ForgotPasswordController.php index d93854e23,000000000..45e40e6fe mode 100644,000000..100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@@ -1,33 -1,0 +1,68 @@@ +middleware('guest'); + parent::__construct(); + } ++ ++ ++ /** ++ * Send a reset link to the given user. ++ * ++ * @param \Illuminate\Http\Request $request ++ * @return \Illuminate\Http\RedirectResponse ++ */ ++ public function sendResetLinkEmail(Request $request) ++ { ++ $this->validate($request, ['email' => 'required|email']); ++ ++ // 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) { ++ $message = 'A password reset link has been sent to ' . $request->get('email') . '.'; ++ session()->flash('success', $message); ++ return back()->with('status', trans($response)); ++ } ++ ++ // If an error was returned by the password broker, we will get this message ++ // translated so we can notify a user of the problem. We'll redirect back ++ // to where the users came from so they can attempt this process again. ++ return back()->withErrors( ++ ['email' => trans($response)] ++ ); ++ } ++ +} diff --combined app/Http/Controllers/Auth/ResetPasswordController.php index 656b8cc42,000000000..bd64793f9 mode 100644,000000..100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@@ -1,33 -1,0 +1,49 @@@ +middleware('guest'); + parent::__construct(); + } ++ ++ /** ++ * Get the response for a successful password reset. ++ * ++ * @param string $response ++ * @return \Illuminate\Http\Response ++ */ ++ protected function sendResetResponse($response) ++ { ++ $message = 'Your password has been successfully reset.'; ++ session()->flash('success', $message); ++ return redirect($this->redirectPath()) ++ ->with('status', trans($response)); ++ } +} diff --combined config/setting-defaults.php index 5482c1331,deafceb29..c681bb7f5 --- a/config/setting-defaults.php +++ b/config/setting-defaults.php @@@ -6,9 -6,10 +6,11 @@@ return [ 'app-name' => 'BookStack', + 'app-name-header' => true, 'app-editor' => 'wysiwyg', 'app-color' => '#0288D1', - 'app-color-light' => 'rgba(21, 101, 192, 0.15)' + 'app-color-light' => 'rgba(21, 101, 192, 0.15)', + 'app-custom-head' => false, + 'registration-enabled' => false, ]; diff --combined resources/assets/sass/_text.scss index fd993b685,8bf09a626..e81061685 --- a/resources/assets/sass/_text.scss +++ b/resources/assets/sass/_text.scss @@@ -15,41 -15,31 +15,41 @@@ h2 margin-bottom: 0.43137255em; } h3 { - font-size: 1.75em; + font-size: 2.333em; line-height: 1.571428572em; margin-top: 0.78571429em; margin-bottom: 0.43137255em; } h4 { - font-size: 1em; + font-size: 1.666em; line-height: 1.375em; margin-top: 0.78571429em; margin-bottom: 0.43137255em; } -h1, h2, h3, h4 { +h1, h2, h3, h4, h5, h6 { font-weight: 400; position: relative; display: block; color: #555; .subheader { - //display: block; font-size: 0.5em; line-height: 1em; color: lighten($text-dark, 32%); } } +h5 { + font-size: 1.4em; +} + +h5, h6 { + font-weight: 500; + line-height: 1.2em; + margin-top: 0.78571429em; + margin-bottom: 0.66em; +} + /* * Link styling */ @@@ -262,7 -252,7 +262,7 @@@ ul ol { list-style: decimal; - padding-left: $-m * 1.3; + padding-left: $-m * 2; overflow: hidden; } diff --combined resources/views/auth/passwords/email.blade.php index d8536efa7,115785ab2..115785ab2 --- a/resources/views/auth/passwords/email.blade.php +++ b/resources/views/auth/passwords/email.blade.php @@@ -1,5 -1,12 +1,12 @@@ @extends('public') + @section('header-buttons') + Sign in + @if(setting('registration-enabled')) + Sign up + @endif + @stop + @section('content') diff --combined resources/views/auth/passwords/reset.blade.php index 9a9a65ff0,612b50ff8..612b50ff8 --- a/resources/views/auth/passwords/reset.blade.php +++ b/resources/views/auth/passwords/reset.blade.php @@@ -1,5 -1,12 +1,12 @@@ @extends('public') + @section('header-buttons') + Sign in + @if(setting('registration-enabled')) + Sign up + @endif + @stop + @section('body-class', 'image-cover login') @section('content') diff --combined resources/views/base.blade.php index 1deed0a3f,961ead251..08acf725d --- a/resources/views/base.blade.php +++ b/resources/views/base.blade.php @@@ -23,7 -23,7 +23,7 @@@ @include('partials/custom-styles') - @if(setting('app-custom-head', false)) + @if(setting('app-custom-head')) {!! setting('app-custom-head') !!} @endif @@@ -39,9 -39,7 +39,9 @@@ @if(setting('app-logo', '') !== 'none') Logo @endif - {{ setting('app-name') }} + @if (setting('app-name-header')) + {{ setting('app-name') }} + @endif
diff --combined resources/views/public.blade.php index 542d5c867,2bce41570..16aebe2bb --- a/resources/views/public.blade.php +++ b/resources/views/public.blade.php @@@ -17,6 -17,11 +17,11 @@@ @include('partials/custom-styles') + + + @if(setting('app-custom-head')) + {!! setting('app-custom-head') !!} + @endif @@@ -31,9 -36,7 +36,9 @@@ @if(setting('app-logo', '') !== 'none') Logo @endif - {{ setting('app-name') }} + @if (setting('app-name-header')) + {{ setting('app-name') }} + @endif
diff --combined tests/Auth/AuthTest.php index 08d5ef8ad,99885d552..0d2e4ac17 --- a/tests/Auth/AuthTest.php +++ b/tests/Auth/AuthTest.php @@@ -1,7 -1,6 +1,7 @@@ setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'true']); $user = factory(\BookStack\User::class)->make(); - // Mock Mailer to ensure mail is being sent - $mockMailer = Mockery::mock('Illuminate\Contracts\Mail\Mailer'); - $mockMailer->shouldReceive('send')->with('emails/email-confirmation', Mockery::type('array'), Mockery::type('callable'))->twice(); - $this->app->instance('mailer', $mockMailer); - // Go through registration process $this->visit('/register') ->see('Sign Up') @@@ -75,10 -76,6 +75,10 @@@ ->seePageIs('/register/confirm') ->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => false]); + // Ensure notification sent + $dbUser = \BookStack\User::where('email', '=', $user->email)->first(); + Notification::assertSentTo($dbUser, ConfirmEmail::class); + // Test access and resend confirmation email $this->login($user->email, $user->password) ->seePageIs('/register/confirm/awaiting') @@@ -87,18 -84,19 +87,18 @@@ ->seePageIs('/register/confirm/awaiting') ->press('Resend Confirmation Email'); - // Get confirmation - $user = $user->where('email', '=', $user->email)->first(); - $emailConfirmation = EmailConfirmation::where('user_id', '=', $user->id)->first(); - - - // Check confirmation email button and confirmation activation. - $this->visit('/register/confirm/' . $emailConfirmation->token . '/email') - ->see('Email Confirmation') - ->click('Confirm Email') + // Get confirmation and confirm notification matches + $emailConfirmation = DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first(); + Notification::assertSentTo($dbUser, ConfirmEmail::class, function($notification, $channels) use ($emailConfirmation) { + return $notification->token === $emailConfirmation->token; + }); + + // Check confirmation email confirmation activation. + $this->visit('/register/confirm/' . $emailConfirmation->token) ->seePageIs('/') ->see($user->name) ->notSeeInDatabase('email_confirmations', ['token' => $emailConfirmation->token]) - ->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => true]); + ->seeInDatabase('users', ['name' => $dbUser->name, 'email' => $dbUser->email, 'email_confirmed' => true]); } public function test_restricted_registration() @@@ -146,7 -144,7 +146,7 @@@ public function test_user_updating() { - $user = \BookStack\User::all()->last(); + $user = $this->getNormalUser(); $password = $user->password; $this->asAdmin() ->visit('/settings/users') @@@ -162,7 -160,7 +162,7 @@@ public function test_user_password_update() { - $user = \BookStack\User::all()->last(); + $user = $this->getNormalUser(); $userProfilePage = '/settings/users/' . $user->id; $this->asAdmin() ->visit($userProfilePage) @@@ -218,6 -216,37 +218,37 @@@ ->seePageIs('/login'); } + public function test_reset_password_flow() + { + $this->visit('/login')->click('Forgot Password?') + ->seePageIs('/password/email') + ->type('admin@admin.com', 'email') + ->press('Send Reset Link') + ->see('A password reset link has been sent to admin@admin.com'); + + $this->seeInDatabase('password_resets', [ + 'email' => 'admin@admin.com' + ]); + + $reset = DB::table('password_resets')->where('email', '=', 'admin@admin.com')->first(); + $this->visit('/password/reset/' . $reset->token) + ->see('Reset Password') + ->submitForm('Reset Password', [ + 'email' => 'admin@admin.com', + 'password' => 'randompass', + 'password_confirmation' => 'randompass' + ])->seePageIs('/') + ->see('Your password has been successfully reset'); + } + + public function test_reset_password_page_shows_sign_links() + { + $this->setSettings(['registration-enabled' => 'true']); + $this->visit('/password/email') + ->seeLink('Sign in') + ->seeLink('Sign up'); + } + /** * Perform a login * @param string $email diff --combined tests/ImageTest.php index 234988ba4,23373419f..031517cdb --- a/tests/ImageTest.php +++ b/tests/ImageTest.php @@@ -10,7 -10,7 +10,7 @@@ class ImageTest extends TestCas */ protected function getTestImage($fileName) { - return new \Illuminate\Http\UploadedFile(base_path('tests/test-image.jpg'), $fileName, 'image/jpeg', 5238); + return new \Illuminate\Http\UploadedFile(base_path('tests/test-data/test-image.jpg'), $fileName, 'image/jpeg', 5238); } /** @@@ -57,12 -57,12 +57,12 @@@ $relPath = $this->uploadImage($imageName, $page->id); $this->assertResponseOk(); - $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image exists'); + $this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image not found at path: '. public_path($relPath)); $this->deleteImage($relPath); $this->seeInDatabase('images', [ - 'url' => url($relPath), + 'url' => $this->baseUrl . $relPath, 'type' => 'gallery', 'uploaded_to' => $page->id, 'path' => $relPath, @@@ -70,7 -70,6 +70,6 @@@ 'updated_by' => $admin->id, 'name' => $imageName ]); - } @@@ -87,7 -86,7 +86,7 @@@ $this->assertResponseOk(); $this->dontSeeInDatabase('images', [ - 'url' => $relPath, + 'url' => $this->baseUrl . $relPath, 'type' => 'gallery' ]);