public function loginSubmit()
 {
     if (CommonUtilities::form_submitted()) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         try {
             if (WSIS::authenticate($username, $password)) {
                 $userRoles = (array) WSIS::getUserRoles($username);
                 if (in_array(Config::get('pga_config.wsis')['admin-role-name'], $userRoles)) {
                     Session::put("admin", true);
                 }
                 if (in_array(Config::get('pga_config.wsis')['read-only-admin'], $userRoles)) {
                     Session::put("admin-read-only", true);
                 }
                 $userProfile = WSIS::getUserProfile($username);
                 if ($userProfile != null && !empty($userProfile)) {
                     Session::put("user-profile", $userProfile);
                 }
                 CommonUtilities::store_id_in_session($username);
                 CommonUtilities::print_success_message('Login successful! You will be redirected to your home page shortly.');
                 //TODO::If this option is not safe, have to find a better method to send credentials to identity server on every connection.
                 Session::put("gateway_id", Config::get('pga_config.airavata')['gateway-id']);
                 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);
         }
     }
 }
 private function sendAccountCreationNotification2Admin($username)
 {
     $mail = new PHPMailer();
     $mail->isSMTP();
     $mail->SMTPDebug = 3;
     $mail->Host = Config::get('pga_config.portal')['portal-smtp-server-host'];
     $mail->SMTPAuth = true;
     $mail->Username = Config::get('pga_config.portal')['portal-email-username'];
     $mail->Password = Config::get('pga_config.portal')['portal-email-password'];
     $mail->SMTPSecure = "tls";
     $mail->Port = intval(Config::get('pga_config.portal')['portal-smtp-server-port']);
     $mail->From = Config::get('pga_config.portal')['portal-email-username'];
     $mail->FromName = "Airavata PHP Gateway";
     $recipients = Config::get('pga_config.portal')['admin-emails'];
     foreach ($recipients as $recipient) {
         $mail->addAddress($recipient);
     }
     $mail->isHTML(true);
     $mail->Subject = "New User Account Was Created Successfully";
     $userProfile = WSIS::getUserProfile($username);
     $wsisConfig = Config::get('pga_config.wsis');
     if ($wsisConfig['tenant-domain'] == "") {
         $username = $username;
     } else {
         $username = $username . "@" . $wsisConfig['tenant-domain'];
     }
     $str = "Gateway Portal: " . $_SERVER['SERVER_NAME'] . "<br/>";
     $str = $str . "Username: "******"<br/>";
     $str = $str . "Name: " . $userProfile["firstname"] . " " . $userProfile["lastname"] . "<br/>";
     $str = $str . "Email: " . $userProfile["email"];
     $mail->Body = $str;
     $mail->send();
 }