1
0
Эх сурвалжийг харах

Add closed registration message instead of 403

Daniel Supernault 6 жил өмнө
parent
commit
9403749d9a

+ 29 - 5
app/Http/Controllers/Auth/RegisterController.php

@@ -39,7 +39,6 @@ class RegisterController extends Controller
     public function __construct()
     {
         $this->middleware('guest');
-        $this->openRegistrationCheck();
     }
 
     /**
@@ -105,11 +104,36 @@ class RegisterController extends Controller
         }
     }
 
-    public function openRegistrationCheck()
+    /**
+     * Show the application registration form.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function showRegistrationForm()
+    {
+        $view = config('pixelfed.open_registration') == true ? 'auth.register' : 'site.closed-registration';
+        return view($view);
+    }
+
+    /**
+     * Handle a registration request for the application.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function register(Request $request)
     {
-        $openRegistration = config('pixelfed.open_registration');
-        if (false == $openRegistration) {
-            abort(403);
+        if(false == config('pixelfed.open_registration')) {
+            return abort(403);
         }
+
+        $this->validator($request->all())->validate();
+
+        event(new Registered($user = $this->create($request->all())));
+
+        $this->guard()->login($user);
+
+        return $this->registered($request, $user)
+                        ?: redirect($this->redirectPath());
     }
 }

+ 14 - 0
resources/views/site/closed-registration.blade.php

@@ -0,0 +1,14 @@
+@extends('layouts.app')
+
+@section('content')
+<div class="container">
+  <div class="error-page py-5 my-5">
+    <div class="card mx-5">
+      <div class="card-body p-5 text-center">
+        <h1>Registration is closed</h1>
+        <p class="lead mb-0">We have closed registrations on this instance.</p>
+      </div>
+    </div>
+  </div>
+</div>
+@endsection