浏览代码

Update logout and middleware

Vijayakrishnan Krishnan 4 年之前
父节点
当前提交
a60a51d96b
共有 3 个文件被更改,包括 15 次插入43 次删除
  1. 2 0
      .env.example
  2. 1 26
      app/Http/Middleware/ProAuthenticated.php
  3. 12 17
      resources/views/layouts/template.blade.php

+ 2 - 0
.env.example

@@ -46,3 +46,5 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
 MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
 
 BACKEND_URL="http://localhost:8080/api"
+
+AUTH_URL=http://localhost:3000

+ 1 - 26
app/Http/Middleware/ProAuthenticated.php

@@ -19,34 +19,9 @@ class ProAuthenticated
         $sessionKey = $request->cookie('sessionKey');
         $appSession = AppSession::where('session_key', $sessionKey)->where('is_active', true)->first();
         $authenticated = $sessionKey && $appSession;
-        $currentRouteName = $request->route()->getName();
 
         if (!$authenticated) {
-            return redirect()->route('login');
-        }
-
-        // - is_two_step_sms_auth_completed
-        if (!$appSession->is_two_step_sms_auth_completed) {
-            if ($currentRouteName != 'confirm_sms_auth_token') {
-                return redirect()->route('confirm_sms_auth_token');
-            }
-            return $next($request);
-        }
-
-        // - is_password_temporary
-        if (!!$appSession->pro->is_password_temporary) {
-            if ($currentRouteName != 'set_password') {
-                return redirect()->route('set_password');
-            }
-            return $next($request);
-        }
-
-        // - are_security_questions_set
-        if (!$appSession->pro->are_security_questions_set) {
-            if ($currentRouteName != 'set_security_questions') {
-                return redirect()->route('set_security_questions');
-            }
-            return $next($request);
+            return redirect(env('AUTH_URL'));
         }
 
         return $next($request);

+ 12 - 17
resources/views/layouts/template.blade.php

@@ -86,38 +86,33 @@
             </div>
             <div class="d-flex align-items-center">
                 <p class="text-white my-0 mr-2 small">Hello, <b title="Cell# {{$pro->cell_number}}">{{ $pro->name_first }}!</b></p>
-                <form action="{{ route('logout') }}" method="post" target="_top">
-                    @csrf
-                    <button class="btn btn-sm btn-link text-light">
-                        <i class="fas fa-sign-out-alt"></i>
-                        <span class="small"></span>Log Out
-                    </button>
-                </form>
+                <a native target="_top" href="{{ env('AUTH_URL') }}/logout" class="btn btn-sm btn-link text-light">
+                    <i class="fas fa-sign-out-alt"></i>
+                    Log Out
+                </a>
             </div>
             @if($pro->pro_type == 'ADMIN')
             <div class="mr-2 d-inline-block">|</div>
             <div class="d-flex align-items-center">
-                <a href="{{route('log-in-as')}}" class="text-white">Log In As</a>
+                <a href="{{route('log-in-as')}}" class="btn btn-sm btn-link text-light p-0">Log In As</a>
             </div>
             @endif
 
             @if($performer->logged_in_as_pro_from_admin_pro_app_session_id)
+            <div class="mx-2 d-inline-block">|</div>
             <form action="{{route('back-to-admin-pro')}}" method="post" target="_top">
                 @csrf
-                <button class="btn btn-sm btn-link text-light">
-                    <i class="fas fa-sign-out-alt"></i>
+                <button class="btn btn-sm btn-link text-light p-0">
                     <span class="small"></span>Back to Admin
                 </button>
             </form>
             @endif
 
             @if($pro->pro_type == 'ADMIN')
-            <div class="ml-2 d-inline-block">|</div>
-            <div class="ml-2 ">
-                <a native target="_top" class="text-light" href="{{env('ADMIN_PORTAL_URL', 'https://pro.securecpu.com')}}/pro_log_in_with_session_key/{{$performer->session_key}}" title="">
-                    Go to Admin Portal
-                </a>
-            </div>
+            <div class="mx-2 d-inline-block">|</div>
+            <a native target="_top" class="btn btn-sm btn-link text-light p-0" href="{{env('ADMIN_PORTAL_URL', 'https://pro.securecpu.com')}}/pro_log_in_with_session_key/{{$performer->session_key}}" title="">
+                Admin Portal
+            </a>
             @endif
 
         </div>
@@ -295,4 +290,4 @@
 
 </body>
 
-</html>
+</html>