public function loginSubmit()
 {
     if (CommonUtilities::form_submitted()) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         try {
             if (WSIS::authenticate($username, $password)) {
                 if (in_array(Config::get('pga_config.wsis')['admin-role-name'], (array) WSIS::getUserRoles($username))) {
                     Session::put("admin", true);
                 }
                 CommonUtilities::store_id_in_session($username);
                 CommonUtilities::print_success_message('Login successful! You will be redirected to your home page shortly.');
                 Session::put("gateway_id", Config::get('pga_config.wsis')['gateway-id']);
                 //TODO::If this option is not safe, have to find a better method to send credentials to identity server on every connection.
                 Session::put("password", $_POST["password"]);
                 return Redirect::to("home");
             } else {
                 return Redirect::to("login")->with("invalid-credentials", true);
             }
         } catch (Exception $ex) {
             return Redirect::to("login")->with("invalid-credentials", true);
         }
     }
 }
 public function addGateway()
 {
     $inputs = Input::all();
     $gateway = AdminUtilities::add_gateway(Input::all());
     $tm = WSIS::createTenant(1, $inputs["admin-username"] . "@" . $inputs["domain"], $inputs["admin-password"], $inputs["admin-email"], $inputs["admin-firstname"], $inputs["admin-lastname"], $inputs["domain"]);
     return $gateway;
 }
Пример #3
0
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
//        To invalidate the SOAP WSDL caches
//        ini_set('soap.wsdl_cache_enabled',0);
//        ini_set('soap.wsdl_cache_ttl',0);
App::before(function ($request) {
    //Check OAuth token has expired
    if (Session::has('authz-token')) {
        $currentTime = time();
        if ($currentTime > Session::get('oauth-expiration-time')) {
            $response = WSIS::getRefreshedOAutheToken(Session::get('oauth-refresh-code'));
            if (isset($response->access_token)) {
                $accessToken = $response->access_token;
                $refreshToken = $response->refresh_token;
                $expirationTime = time() + $response->expires_in - 300;
                $authzToken = Session::get('authz-token');
                $authzToken->accessToken = $accessToken;
                Session::put('authz-token', $authzToken);
                Session::put('oauth-refresh-code', $refreshToken);
                Session::put('oauth-expiration-time', $expirationTime);
            } else {
                Session::flush();
                return Redirect::to('home');
            }
        }
    }
 public function addGateway()
 {
     $inputs = Input::all();
     $gateway = AdminUtilities::add_gateway(Input::all());
     $tm = WSIS::createTenant(1, $inputs["admin-username"] . "@" . $inputs["domain"], $inputs["admin-password"], $inputs["admin-email"], $inputs["admin-firstname"], $inputs["admin-lastname"], $inputs["domain"]);
     Session::put("message", "Gateway " . $inputs["gatewayName"] . " has been added.");
     return Response::json($tm);
     //return Redirect::to("admin/dashboard/gateway")->with("message", "Gateway has been successfully added.");
 }
 public function resetPasswordSubmit()
 {
     $rules = array("new_password" => "required|min:6", "confirm_new_password" => "required|same:new_password");
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to("reset-password")->withInput(Input::except('new_password', 'confirm)new_password'))->withErrors($validator);
     }
     $key = $_POST['key'];
     $username = $_POST['username'];
     $new_password = $_POST['new_password'];
     try {
         $result = WSIS::resetPassword($username, $new_password, $key);
         if ($result) {
             CommonUtilities::print_success_message("User password was reset successfully");
             return View::make("account/login");
         } else {
             CommonUtilities::print_error_message("Resetting user password operation failed");
             return View::make("account/home");
         }
     } catch (Exception $e) {
         CommonUtilities::print_error_message("Resetting user password operation failed");
         return View::make("account/home");
     }
 }