You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2015/10/25 15:53:30 UTC

airavata-php-gateway git commit: sending account creation emails to the PIs

Repository: airavata-php-gateway
Updated Branches:
  refs/heads/master 63af3b5b3 -> f6af261ec


sending account creation emails to the PIs


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/f6af261e
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/f6af261e
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/f6af261e

Branch: refs/heads/master
Commit: f6af261ec1aeb723bb61b03509b222ee2c5bb233
Parents: 63af3b5
Author: scnakandala <su...@gmail.com>
Authored: Sun Oct 25 10:53:24 2015 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Sun Oct 25 10:53:24 2015 -0400

----------------------------------------------------------------------
 app/config/pga_config.php.template    | 22 +++++++++++++++++-
 app/controllers/AccountController.php | 37 ++++++++++++++++++++++++++++++
 composer.json                         |  3 ++-
 3 files changed, 60 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f6af261e/app/config/pga_config.php.template
----------------------------------------------------------------------
diff --git a/app/config/pga_config.php.template b/app/config/pga_config.php.template
index 619354c..770edd6 100644
--- a/app/config/pga_config.php.template
+++ b/app/config/pga_config.php.template
@@ -175,6 +175,26 @@ return array(
          * Email address of the portal admin. Portal admin well get email notifications for events
          * such as new user creation
          */
-        'admin-email' => 'abc@xyz.com'
+        'admin-emails' => ['xxx@xxx.com','yyy@yyy.com'],
+
+        /**
+         * Email account that the portal should login to send emails
+         */
+        'portal-email-username' => 'xyz@abc.com',
+
+        /**
+         * Password for the portal's email account
+         */
+        'portal-email-password' => 'xxxxxxxxxxx',
+
+        /**
+         * SMTP server on which the portal should connect
+         */
+        'portal-smtp-server-host' => 'smtp.gmail.com',
+
+        /**
+         * SMTP server port on which the portal should connect
+         */
+        'portal-smtp-server-port' => '587'
     ]
 );
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f6af261e/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index e483d0c..3c617d6 100755
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -273,6 +273,7 @@ class AccountController extends BaseController
             try{
                 $result = WSIS::confirmUserRegistration($username, $confirmation, Config::get('pga_config.wsis')['tenant-domain']);
                 if($result){
+                    $this->sendAccountCreationNotification2Admin($username);
                     return Redirect::to("login");
                 }else{
                     CommonUtilities::print_error_message("Account confirmation failed!");
@@ -285,6 +286,42 @@ class AccountController extends BaseController
         }
     }
 
+    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);
+        $str = "Username: " . $username . "@" . Config::get('pga_config.wsis')['tenant-domain'] . "<br/>";
+        $str = $str . "Name: " . $userProfile["firstname"] . " " . $userProfile["lastname"] . "<br/>";
+        $str = $str . "Email: " . $userProfile["email"];
+
+        $mail->Body = $str;
+        $mail->send();
+    }
+
     public function resetPasswordSubmit()
     {
         $rules = array(

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f6af261e/composer.json
----------------------------------------------------------------------
diff --git a/composer.json b/composer.json
index d8978db..e9d4734 100755
--- a/composer.json
+++ b/composer.json
@@ -5,7 +5,8 @@
     "license": "MIT",
     "require": {
         "laravel/framework": "4.2.*",
-        "teepluss/theme": "1.*@dev"
+        "teepluss/theme": "1.*@dev",
+        "phpmailer/phpmailer": "v5.2.13"
     },
     "autoload": {
         "classmap": [