PHP code example of glz / nvwa-core

1. Go to this page and download the library: Download glz/nvwa-core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

glz / nvwa-core example snippets


    /**
    * 本方法服务于URL:remoteUser/login
    */
  public function login(Request $request){
        $currentUser = $request->user();
        if($currentUser){
            $serverSide = new ServerSide();
            return $serverSide->redirectToClientWithRemoteUserInfo($request);
        }else{
            return redirect("/auth/login?redirectTo=".urlencode($request->url()."?".$request->getQueryString()));
        }
        
    }

    Route::group(["middleware"=>'remoteUser'],function(){
        Route::get("/home",'\App\Http\Controllers\HomeController@home');
        //....及其他的urls的处理逻辑;
    });

    class HomeController extends Controller {
        public  function home(Request $request){
            $user =  RemoteUser::getCurrentUser();
            return $user->getId().":".$user->getName().":".$user->getEmail();
        }
    }
ini
REMOTE_USER_SECRET=gdsdddddd333
app/Http/Kernel.php