authserver/testCAS/app/Http/Controllers/HomeController.php
author durandn
Fri, 28 Aug 2015 16:00:19 +0200
changeset 82 bf1c38268e25
parent 9 3166a35f5f0d
child 95 8ecee14c6d81
permissions -rw-r--r--
Updated Readmes + Updated tmp CAS config + Updated Laravel test with iframe + remove X-Frame django middleware from middlewares + removed local ssl certificate from repo

<?php namespace TestCAS\Http\Controllers;

use Cas;
use phpCAS;

class HomeController extends Controller {

    /*
    |--------------------------------------------------------------------------
    | Home Controller
    |--------------------------------------------------------------------------
    |
    | This controller renders your application's "dashboard" for users that
    | are authenticated. Of course, you are free to change or remove the
    | controller as you wish. It is just here to get your app started!
    |
    */

    /**
    * Create a new controller instance.
    *
    * @return void
    */
    public function __construct()
    {
        $this->middleware('auth.cas');
    }

    /**
    * Show the application dashboard to the user.
    *
    * @return Response
    */
    public function index()
    {
        $pt="Error getting PT";
        $pt=phpCAS::retrievePT(env("LDT_URL")."/remie/workunit/segments_single?project_id=".env("TEST_PROJECT_ID"), $err_code, $err_msg);
        $iframe_url=env("LDT_URL")."/remie/workunit/segments_single?project_id=".env("TEST_PROJECT_ID")."&casticket=".$pt;

        $loginUrl=env("LDT_URL")."/accounts/cas/login";

        return view('home')->with(
          array("pt" => $pt, "err_code" => $err_code, "err_msg" => $err_msg, "iframe_url" => $iframe_url, 'loginUrl' => $loginUrl)
        );
    }

    /**
    * logout
    *
    * @return Response
    */
    public function logout()
    {
        cas::logout(['service'=>url('/')]);
        return redirect()->route('index');
    }

}