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/13 05:18:11 UTC
[1/2] airavata-php-gateway git commit: User email verification when
creating a user account
Repository: airavata-php-gateway
Updated Branches:
refs/heads/master cf050d52b -> d7e5b727e
User email verification when creating a user account
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/42e8876b
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/42e8876b
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/42e8876b
Branch: refs/heads/master
Commit: 42e8876bac60f262695ddac443697ddd6dc938f8
Parents: c0780d5
Author: scnakandala <su...@gmail.com>
Authored: Mon Oct 12 23:17:57 2015 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Mon Oct 12 23:17:57 2015 -0400
----------------------------------------------------------------------
app/config/pga_config.php.template | 5 ++
app/controllers/AccountController.php | 57 +++++++++++++-----
app/filters.php | 4 ++
.../Stubs/UserInformationRecoveryManager.php | 63 ++++++++++++++++++++
app/libraries/Wsis/Stubs/UserStoreManager.php | 4 +-
app/libraries/Wsis/Wsis.php | 52 +++++++++++++++-
app/routes.php | 2 +
app/views/account/create.blade.php | 2 +
8 files changed, 169 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/42e8876b/app/config/pga_config.php.template
----------------------------------------------------------------------
diff --git a/app/config/pga_config.php.template b/app/config/pga_config.php.template
index 292ecc2..535fdea 100644
--- a/app/config/pga_config.php.template
+++ b/app/config/pga_config.php.template
@@ -24,6 +24,11 @@ return array(
'user-role-name' => 'airavata-user',
/**
+ * Tenant Domain
+ */
+ 'tenant-domain' => 'master.airavata',
+
+ /**
* Tenant admin's username
*/
'admin-username' => 'master@master.airavata',
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/42e8876b/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index eac2f0b..afe7bd3 100755
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -12,7 +12,7 @@ class AccountController extends BaseController
{
$rules = array(
"username" => "required|min:6",
- "password" => "required|min:6",
+ "password" => "required|min:6|(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*\W).{6,16})",
"confirm_password" => "required|same:password",
"email" => "required|email",
);
@@ -54,20 +54,24 @@ class AccountController extends BaseController
->withInput(Input::except('password', 'password_confirm'))
->with("username_exists", true);
} else {
- WSIS::addUser($username, $password, $first_name, $last_name, $email, $organization,
- $address, $country, $telephone, $mobile, $im, $url);
-
- //update user profile
- WSIS::updateUserProfile($username, $email, $first_name, $last_name);
-
- CommonUtilities::print_success_message('New user created!');
-
- if(Config::get('pga_config.wsis')['auth-mode']=="oauth"){
- return View::make('home');
- }else{
- return View::make('account/login');
- }
-
+// WSIS::addUser($username, $password);
+//
+// //update user profile
+// WSIS::updateUserProfile($username, $email, $first_name, $last_name);
+//
+// CommonUtilities::print_success_message('New user created!');
+//
+// if(Config::get('pga_config.wsis')['auth-mode']=="oauth"){
+// return View::make('home');
+// }else{
+// return View::make('account/login');
+// }
+
+ WSIS::registerUserAccount($username, $password, $email, $first_name, $last_name,
+ Config::get('pga_config.wsis')['tenant-domain']);
+
+ CommonUtilities::print_success_message('Account confirmation request was sent to your email account');
+ return View::make('home');
}
}
@@ -237,7 +241,7 @@ class AccountController extends BaseController
if(empty($username) || empty($confirmation)){
return View::make("home");
}else{
- $username = $username . "@" . explode("@",Config::get('pga_config.wsis')['admin-username'])[1];
+ $username = $username . "@" . Config::get('pga_config.wsis')['tenant-domain'];
try{
$key = WSIS::validateConfirmationCode($username, $confirmation);
if(!empty($key)){
@@ -252,6 +256,27 @@ class AccountController extends BaseController
}
+ public function confirmAccountCreation()
+ {
+ $confirmation = Input::get("confirmation");
+ $username = Input::get("username");
+ if(empty($username) || empty($confirmation)){
+ return View::make("home");
+ }else{
+ try{
+ $result = WSIS::confirmUserRegistration($username, $confirmation, Config::get('pga_config.wsis')['tenant-domain']);
+ if($result){
+ return View::make("account/login");
+ }else{
+ return View::make("home");
+ }
+ }catch (Exception $e){
+ var_dump($e);exit;
+ return View::make("home");
+ }
+ }
+ }
+
public function resetPasswordSubmit()
{
$rules = array(
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/42e8876b/app/filters.php
----------------------------------------------------------------------
diff --git a/app/filters.php b/app/filters.php
index 1446331..aa022ac 100755
--- a/app/filters.php
+++ b/app/filters.php
@@ -11,6 +11,10 @@
|
*/
+// 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(Config::get('pga_config.wsis')['auth-mode']=="oauth" && Session::has('authz-token')){
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/42e8876b/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php b/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php
index a9df7c6..e03788d 100755
--- a/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php
+++ b/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php
@@ -1,6 +1,7 @@
<?php
namespace Wsis\Stubs;
+use Illuminate\Support\Facades\Config;
use Wsis\Stubs\UserInformationRecoveryStub;
/**
@@ -88,4 +89,66 @@ class UserInformationRecoveryManager {
$result = $this->serviceStub->updatePassword($updatePassword);
return $result->return->verified;
}
+
+
+ /**
+ * Function to create a user account. This user account is not activate unless activated by the user
+ * via email
+ * @param $username
+ * @param $password
+ * @param $email
+ * @param $firstName
+ * @param $lastName
+ * @param $tenantDomain
+ * @return mixed
+ */
+ public function registerAccount($username, $password, $email,$firstName, $lastName, $tenantDomain){
+
+ $registerUser = new registerUser();
+ $registerUser->userName = $username;
+ $registerUser->password = $password;
+ $registerUser->profileName = "default";
+ $registerUser->tenantDomain = $tenantDomain;
+
+ $fieldValues = array();
+ $usernameDTO = new UserIdentityClaimDTO();
+ $usernameDTO->claimUri = "http://wso2.org/claims/username";
+ $usernameDTO->claimValue = $username;
+ array_push($fieldValues, $usernameDTO);
+
+ $emailDTO = new UserIdentityClaimDTO;
+ $emailDTO->claimUri = "http://wso2.org/claims/emailaddress";
+ $emailDTO->claimValue = $email;
+ array_push($fieldValues, $emailDTO);
+
+ $firstNameDTO = new UserIdentityClaimDTO();
+ $firstNameDTO->claimUri = "http://wso2.org/claims/givenname";
+ $firstNameDTO->claimValue = $firstName;
+ array_push($fieldValues, $firstNameDTO);
+
+ $lastNameDTO = new UserIdentityClaimDTO();
+ $lastNameDTO->claimUri = "http://wso2.org/claims/lastname";
+ $lastNameDTO->claimValue = $lastName;
+ array_push($fieldValues, $lastNameDTO);
+ $registerUser->claims = $fieldValues;
+
+ $result = $this->serviceStub->registerUser($registerUser);
+ return $result->return->verified;
+ }
+
+
+ /**
+ * Function to confirm user registration
+ * @param $userName
+ * @param $tenantDomain
+ */
+ public function confirmUserRegistration($userName, $code, $tenantDomain){
+ $confirmUserSelfRegistration = new confirmUserSelfRegistration();
+ $confirmUserSelfRegistration->username = $userName;
+ $confirmUserSelfRegistration->code = $code;
+ $confirmUserSelfRegistration->tenantDomain = $tenantDomain;
+ $result = $this->serviceStub->confirmUserSelfRegistration($confirmUserSelfRegistration);
+ return $result->return->verified;
+ return $result->return->verified;
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/42e8876b/app/libraries/Wsis/Stubs/UserStoreManager.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Stubs/UserStoreManager.php b/app/libraries/Wsis/Stubs/UserStoreManager.php
index 479b320..706f847 100755
--- a/app/libraries/Wsis/Stubs/UserStoreManager.php
+++ b/app/libraries/Wsis/Stubs/UserStoreManager.php
@@ -49,12 +49,12 @@ class UserStoreManager {
* @param type $userName
* @param type $password
*/
- public function addUser($userName, $password, $fullName){
+ public function addUser($userName, $password){
$parameters = new AddUser();
$parameters->userName = $userName;
$parameters->credential = $password;
$parameters->claims = null;
- $parameters->profileName = $fullName;
+ $parameters->profileName = "default";
$parameters->requirePasswordChange = false;
$parameters->roleList = null;
$this->serviceStub->addUser($parameters);
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/42e8876b/app/libraries/Wsis/Wsis.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Wsis.php b/app/libraries/Wsis/Wsis.php
index 221d943..b684887 100755
--- a/app/libraries/Wsis/Wsis.php
+++ b/app/libraries/Wsis/Wsis.php
@@ -111,14 +111,35 @@ class Wsis {
* @return void
* @throws Exception
*/
- public function addUser($userName, $password, $fullName) {
+ public function addUser($userName, $password) {
try {
- $this->userStoreManager->addUser($userName, $password, $fullName);
+ $this->userStoreManager->addUser($userName, $password);
} catch (Exception $ex) {
throw new Exception("Unable to add new user", 0, $ex);
}
}
+
+ /**
+ * Function to create a new user account. This user account is not active unless activates by the user via
+ * his/her email
+ *
+ * @param $userName
+ * @param $password
+ * @param $email
+ * @param $firstName
+ * @param $lastName
+ * @param $tenantDomain
+ * @throws Exception
+ */
+ public function registerAccount($userName, $password, $email, $firstName, $lastName, $tenantDomain){
+ try {
+ $this->userInfoRecoveryManager->registerAccount($userName, $password, $email, $firstName, $lastName, $tenantDomain);
+ } catch (Exception $ex) {
+ throw new Exception("Unable to create a new user account", 0, $ex);
+ }
+ }
+
/**
* Function to delete existing user
*
@@ -397,6 +418,33 @@ class Wsis {
$this->userProfileManager->updateUserProfile($username, $email, $firstName, $lastName);
}
+
+ /**
+ *
+ * Function to create a user account. This user account has to be activated by the user via his
+ * email account
+ * @param $username
+ * @param $password
+ * @param $email
+ * @param $firstName
+ * @param $lastName
+ * @param $tenantDomain
+ */
+ public function registerUserAccount($username, $password, $email, $firstName, $lastName, $tenantDomain)
+ {
+ $this->userInfoRecoveryManager->registerAccount($username, $password, $email, $firstName,
+ $lastName, $tenantDomain);
+ }
+
+ /**
+ * Function to confirm user registration
+ * @param $userName
+ * @param $tenantDomain
+ */
+ public function confirmUserRegistration($userName, $code, $tenantDomain){
+ return $this->userInfoRecoveryManager->confirmUserRegistration($userName, $code, $tenantDomain);
+ }
+
/**
* Function to get the user profile of a user
* @param $username
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/42e8876b/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 7e1a83c..0aaef26 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -42,6 +42,8 @@ Route::post("reset-password", "AccountController@resetPasswordSubmit");
Route::post("forgot-password", "AccountController@forgotPasswordSubmit");
+Route::get("confirm-user-registration", "AccountController@confirmAccountCreation");
+
Route::get("setUserTimezone", function () {
Session::set("user_timezone", Input::get("timezone"));
});
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/42e8876b/app/views/account/create.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/create.blade.php b/app/views/account/create.blade.php
index e7b3a32..ee4ca2b 100755
--- a/app/views/account/create.blade.php
+++ b/app/views/account/create.blade.php
@@ -40,6 +40,8 @@
<div><input class="form-control" id="password" minlength="6" name="password" placeholder="Password"
required="required" title="" type="password"/></div>
+ <div><small>(Password should contain a digit[0-9], a lower case letter[a-z], an upper case letter[A-Z],
+ one of !@#$%&* characters)</small></div>
</div>
<div class="form-group required"><label class="control-label">Password (again)</label>
[2/2] airavata-php-gateway git commit: Merge remote-tracking branch
'origin/master'
Posted by sc...@apache.org.
Merge remote-tracking branch 'origin/master'
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/d7e5b727
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/d7e5b727
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/d7e5b727
Branch: refs/heads/master
Commit: d7e5b727ea4305a669b747160a3a0157576dac0d
Parents: 42e8876 cf050d5
Author: scnakandala <su...@gmail.com>
Authored: Mon Oct 12 23:18:08 2015 -0400
Committer: scnakandala <su...@gmail.com>
Committed: Mon Oct 12 23:18:08 2015 -0400
----------------------------------------------------------------------
app/config/pga_config.php.template | 5 -
app/controllers/GatewayprofileController.php | 11 ++
app/libraries/Airavata/API/Airavata.php | 101 +++++++++----------
app/libraries/CRUtilities.php | 8 +-
app/libraries/ExperimentUtilities.php | 6 +-
app/routes.php | 22 ++--
app/views/admin/manage-gateway.blade.php | 35 ++++++-
app/views/layout/basic.blade.php | 7 ++
.../partials/gateway-preferences.blade.php | 9 ++
public/css/admin.css | 6 +-
10 files changed, 136 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d7e5b727/app/config/pga_config.php.template
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d7e5b727/app/routes.php
----------------------------------------------------------------------