]> BookStack Code Mirror - bookstack/commitdiff
Merge fixes from branch 'v0.12'
authorDan Brown <redacted>
Sat, 12 Nov 2016 11:40:54 +0000 (11:40 +0000)
committerDan Brown <redacted>
Sat, 12 Nov 2016 11:40:54 +0000 (11:40 +0000)
13 files changed:
app/Http/Controllers/Auth/ForgotPasswordController.php
app/Http/Controllers/Auth/ResetPasswordController.php
config/setting-defaults.php
resources/assets/sass/_blocks.scss
resources/assets/sass/_text.scss
resources/views/auth/passwords/email.blade.php
resources/views/auth/passwords/reset.blade.php
resources/views/base.blade.php
resources/views/pages/pdf.blade.php
resources/views/public.blade.php
tests/Auth/AuthTest.php
tests/Entity/EntitySearchTest.php
tests/ImageTest.php

index d93854e23a49d947ffc68188f8929956d92874b1..45e40e6fe8371a5d8034ca2d5627f2ff63621acc 100644 (file)
@@ -4,6 +4,8 @@ namespace BookStack\Http\Controllers\Auth;
 
 use BookStack\Http\Controllers\Controller;
 use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
+use Illuminate\Http\Request;
+use Password;
 
 class ForgotPasswordController extends Controller
 {
@@ -30,4 +32,37 @@ class ForgotPasswordController extends Controller
         $this->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)]
+        );
+    }
+
 }
\ No newline at end of file
index 656b8cc42418a63840fe2c32946100e952ee64f0..bd64793f9223078d375da6577af9a01cfd1a9fae 100644 (file)
@@ -20,6 +20,8 @@ class ResetPasswordController extends Controller
 
     use ResetsPasswords;
 
+    protected $redirectTo = '/';
+
     /**
      * Create a new controller instance.
      *
@@ -30,4 +32,18 @@ class ResetPasswordController extends Controller
         $this->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));
+    }
 }
\ No newline at end of file
index 5482c13315e8012f9f90f89644e765d895eb1569..c681bb7f55ddbe97e6ba73b29154373e18d2db55 100644 (file)
@@ -9,6 +9,8 @@ return [
     '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,
 
 ];
\ No newline at end of file
index 3c7f7490b0de89c0b83ad694e5f110ed3db486d2..727633f757f6a98fa6e97b5aa8b2e41ea1557d78 100644 (file)
   border-left: 3px solid #BBB;
   background-color: #EEE;
   padding: $-s;
+  display: flex;
   &:before {
     font-family: 'Material-Design-Iconic-Font';
     padding-right: $-s;
index fd993b685402813132cb3a4c0ff50405bc20b153..e81061685a1ab3afc1d37a8fdb4fab78a4fe0987 100644 (file)
@@ -262,7 +262,7 @@ ul {
 
 ol {
   list-style: decimal;
-  padding-left: $-m * 1.3;
+  padding-left: $-m * 2;
   overflow: hidden;
 }
 
index d8536efa723bebef008e1feb194c682fd773a394..115785ab2eb43893df69e64b3573c7aa3b3a9101 100644 (file)
@@ -1,5 +1,12 @@
 @extends('public')
 
+@section('header-buttons')
+    <a href="{{ baseUrl("/login") }}"><i class="zmdi zmdi-sign-in"></i>Sign in</a>
+    @if(setting('registration-enabled'))
+        <a href="{{ baseUrl("/register") }}"><i class="zmdi zmdi-account-add"></i>Sign up</a>
+    @endif
+@stop
+
 @section('content')
 
 
index 9a9a65ff094516af8ac142e3b898222f0c2589fd..612b50ff835eb069f54b77ae0bf8af91c8d09acf 100644 (file)
@@ -1,5 +1,12 @@
 @extends('public')
 
+@section('header-buttons')
+    <a href="{{ baseUrl("/login") }}"><i class="zmdi zmdi-sign-in"></i>Sign in</a>
+    @if(setting('registration-enabled'))
+        <a href="{{ baseUrl("/register") }}"><i class="zmdi zmdi-account-add"></i>Sign up</a>
+    @endif
+@stop
+
 @section('body-class', 'image-cover login')
 
 @section('content')
index 1deed0a3fbad2057fc5ca0789f2a6029d7f24d45..08acf725d95ea013b54fcd0742060d87e9d571ed 100644 (file)
@@ -23,7 +23,7 @@
     @include('partials/custom-styles')
 
     <!-- Custom user content -->
-    @if(setting('app-custom-head', false))
+    @if(setting('app-custom-head'))
         {!! setting('app-custom-head') !!}
     @endif
 </head>
index 0cbf4df02a32ec16f7ee99f00e4730236a034ec1..5c9fd5eea8707fad42b2ea5b982f3b78266a5f1c 100644 (file)
@@ -14,7 +14,7 @@
         table {
             max-width: 800px !important;
             font-size: 0.8em;
-            width: auto !important;
+            width: 100% !important;
         }
 
         table td {
index 542d5c8679add17afe29e4070f456616fc21cbf8..16aebe2bb74fcede0efea22af753c41ec920b46b 100644 (file)
     <!-- Scripts -->
     <script src="{{ baseUrl("/libs/jquery/jquery.min.js?version=2.1.4") }}"></script>
     @include('partials/custom-styles')
+
+    <!-- Custom user content -->
+    @if(setting('app-custom-head'))
+        {!! setting('app-custom-head') !!}
+    @endif
 </head>
 <body class="@yield('body-class')" ng-app="bookStack">
 
index 08d5ef8adb296eaea113da265d7afe2339a4d716..0d2e4ac170a660e3ed0925f65df404e915a1c398 100644 (file)
@@ -218,6 +218,37 @@ class AuthTest extends TestCase
             ->seePageIs('/login');
     }
 
+    public function test_reset_password_flow()
+    {
+        $this->visit('/login')->click('Forgot Password?')
+            ->seePageIs('/password/email')
+            ->type('[email protected]', 'email')
+            ->press('Send Reset Link')
+            ->see('A password reset link has been sent to [email protected]');
+
+        $this->seeInDatabase('password_resets', [
+            'email' => '[email protected]'
+        ]);
+
+        $reset = DB::table('password_resets')->where('email', '=', '[email protected]')->first();
+        $this->visit('/password/reset/' . $reset->token)
+            ->see('Reset Password')
+            ->submitForm('Reset Password', [
+                'email' => '[email protected]',
+                '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
index 8adfd35a3e3c59037c2cb8e8e1f7574bf46adc66..cfdabdb0ac9efbe500aa2a20017538899e4d0bb7 100644 (file)
@@ -91,6 +91,12 @@ class EntitySearchTest extends TestCase
             ->see('Book Search Results')->see('.entity-list', $book->name);
     }
 
+    public function test_searching_hypen_doesnt_break()
+    {
+        $this->visit('/search/all?term=cat+-')
+            ->seeStatusCode(200);
+    }
+
     public function test_ajax_entity_search()
     {
         $page = \BookStack\Page::all()->last();
index 234988ba402c18da448ac0d5714c86f4b88edc50..031517cdb019d1d9380cf4161fc4dd44346d4399 100644 (file)
@@ -57,7 +57,7 @@ class ImageTest extends TestCase
         $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);
 
@@ -70,7 +70,6 @@ class ImageTest extends TestCase
             'updated_by' => $admin->id,
             'name' => $imageName
         ]);
-        
 
     }