You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by nd...@apache.org on 2016/07/14 08:08:43 UTC
airavata-php-gateway git commit: Gateway Request Ideal Flow complete
- validations not present
Repository: airavata-php-gateway
Updated Branches:
refs/heads/develop 415edc50c -> 4af8a9ad9
Gateway Request Ideal Flow complete - validations not present
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/4af8a9ad
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/4af8a9ad
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/4af8a9ad
Branch: refs/heads/develop
Commit: 4af8a9ad93ed7e7decfb325281fb34afc63d2ce6
Parents: 415edc5
Author: Nipurn Doshi <ni...@gmail.com>
Authored: Thu Jul 14 01:07:57 2016 -0700
Committer: Nipurn Doshi <ni...@gmail.com>
Committed: Thu Jul 14 01:07:57 2016 -0700
----------------------------------------------------------------------
app/controllers/AccountController.php | 8 ++-
app/controllers/AdminController.php | 69 ++++++++++++++++++++----
app/controllers/GatewayController.php | 13 ++---
app/libraries/AdminUtilities.php | 48 ++++++++++++-----
app/libraries/CRUtilities.php | 1 -
app/routes.php | 4 +-
app/views/account/dashboard.blade.php | 76 ++++++++++++---------------
app/views/admin/manage-gateway.blade.php | 30 ++++++++---
8 files changed, 160 insertions(+), 89 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4af8a9ad/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index a778165..601ad8e 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -297,7 +297,9 @@ class AccountController extends BaseController
if( in_array( "gateway-provider", $userProfile["roles"]) ) {
$gatewayOfUser = "";
+
$gatewaysInfo = CRUtilities::getAllGateways();
+ var_dump( $gatewaysInfo); exit;
foreach ($gatewaysInfo as $index => $gateway) {
if ($gateway->emailAddress == $userProfile["email"]) {
Session::set("gateway_id", $gateway->gatewayId);
@@ -312,12 +314,8 @@ class AccountController extends BaseController
Session::put("new-gateway-provider", true);
}
}
-
- $errors = array();
- if( Session::has("errors"))
- $errors = Session::get("errors");
- return View::make("account/dashboard",array("message"=> implode( "," , $errors) ));
+ return View::make("account/dashboard");
}
public function resetPassword()
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4af8a9ad/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index f289e07..e27c30b 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -13,21 +13,29 @@ class AdminController extends BaseController {
$userProfile = Session::get("user-profile");
Session::forget("new-gateway-provider");
-
- if( in_array( "gateway-provider", $userProfile["roles"]) ){
- $gatewayOfUser = "";
- $gatewaysInfo = CRUtilities::getAllGateways();
- foreach( $gatewaysInfo as $index => $gateway){
- if( $gateway->emailAddress == $userProfile["email"]){
+ if( in_array( "gateway-provider", $userProfile["roles"]) ) {
+ $gatewayOfUser = "";
+ $gatewaysInfo = CRUtilities::getAllGateways();
+ //var_dump( $gatewaysInfo); exit;
+ foreach ($gatewaysInfo as $index => $gateway) {
+ if ($gateway->identityServerUserName == $userProfile["username"]) {
Session::set("gateway_id", $gateway->gatewayId);
$gatewayOfUser = $gateway->gatewayId;
Session::forget("super-admin");
+ Session::put("existing-gateway-provider", true);
+ if( $gateway->gatewayApprovalStatus == 0){
+ Session::put("approvalStatus", "Requested");
+ }
+ elseif( $gateway->gatewayApprovalStatus == 3){
+ Session::put("approvalStatus", "Denied");
+ }
break;
}
}
- if( $gatewayOfUser == ""){
- $userInfo["username"] = $userProfile["username"];
- $userInfo["email"] = $userProfile["email"];
+
+ if ($gatewayOfUser == "") {
+ $userInfo["username"] = $userProfile["username"];
+ $userInfo["email"] = $userProfile["email"];
Session::put("new-gateway-provider", true);
}
}
@@ -131,6 +139,12 @@ class AdminController extends BaseController {
}
}
+ public function updateGatewayRequest(){
+ AdminUtilities::update_gateway_status( Input::get("gateway_id"), Input::get("status"));
+
+ return Redirect::to("admin/dashboard/gateway");
+ }
+
public function rolesView(){
$roles = WSIS::getAllRoles();
Session::put("admin-nav", "manage-roles");
@@ -374,6 +388,43 @@ class AdminController extends BaseController {
}
}
+
+ public function requestGateway(){
+ $inputs = Input::all();
+
+ $rules = array(
+ "username" => "required|min:6",
+ "password" => "required|min:6|max:48|regex:/^.*(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@!$#*]).*$/",
+ "confirm_password" => "required|same:password",
+ "email" => "required|email",
+ );
+
+ $messages = array(
+ 'password.regex' => 'Password needs to contain at least (a) One lower case letter (b) One Upper case letter and (c) One number (d) One of the following special characters - !@#$&*',
+ );
+
+ $checkValidation = array();
+ $checkValidation["username"] = $inputs["admin-username"];
+ $checkValidation["password"] = $inputs["admin-password"];
+ $checkValidation["confirm_password"] = $inputs["admin-password-confirm"];
+ $checkValidation["email"] = $inputs["email-address"];
+
+ $validator = Validator::make( $checkValidation, $rules, $messages);
+ if ($validator->fails()) {
+ Session::put("message", $validator->messages() );
+ return Redirect::to("admin/dashboard");
+ }
+ else{
+ $gateway = AdminUtilities::request_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", "Your request for Gateway " . $inputs["gateway-name"] . " has been created.");
+
+ return Redirect::to("admin/dashboard");
+ }
+ }
+
public function enableComputeResource(){
$resourceId = Input::get("resourceId");
$computeResource = CRUtilities::get_compute_resource($resourceId);
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4af8a9ad/app/controllers/GatewayController.php
----------------------------------------------------------------------
diff --git a/app/controllers/GatewayController.php b/app/controllers/GatewayController.php
index 4f13c57..48d42e5 100644
--- a/app/controllers/GatewayController.php
+++ b/app/controllers/GatewayController.php
@@ -20,24 +20,19 @@ class GatewayController extends BaseController {
$checkValidation["username"] = $inputs["admin-username"];
$checkValidation["password"] = $inputs["admin-password"];
$checkValidation["confirm_password"] = $inputs["admin-password-confirm"];
- $checkValidation["email"] = $inputs["admin-email"];
+ $checkValidation["email"] = $inputs["email-address"];
$validator = Validator::make( $checkValidation, $rules, $messages);
if ($validator->fails()) {
- return Redirect::to("account/dashboard", array( "errors"=>$validator->messages() );
+ Session::put("message", implode(",", $validator->messages() ));
+ return Redirect::to("admin/dashboard");
}
else{
$gateway = AdminUtilities::request_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", "Your request for Gateway " . $inputs["gatewayName"] . " has been created.");
- return Response::json( array( "gateway" =>$gateway, "tm" => $tm ) );
- if( $gateway == $inputs["gatewayName"] && is_object( $tm ) )
- return Response::json( array( "gateway" =>$gateway, "tm" => $tm ) );
- else
- return 0;
+ return Redirect::to("admin/dashboard");
}
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4af8a9ad/app/libraries/AdminUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php
index 16fca27..2057a29 100644
--- a/app/libraries/AdminUtilities.php
+++ b/app/libraries/AdminUtilities.php
@@ -1,6 +1,7 @@
<?php
use Airavata\Model\Workspace\Gateway;
+use Airavata\Model\Workspace\GatewayApprovalStatus;
use Airavata\Model\Workspace\Notification;
use Airavata\Model\Workspace\NotificationPriority;
@@ -24,22 +25,41 @@ class AdminUtilities
public static function request_gateway( $inputs)
{
- $gateway = new Gateway( $input);
- $gateway->gatewayId = $input["gateway-name"];
- $gateway->GatewayApprovalStatus = GatewayApprovalStatus::REQUESTED;
- $gateway->domain = $input["domain"];
- $gateway->gatewayName = $input["gateway-name"];
- $gateway->emailAddress = $input["admin-email"];
- $gateway->gatewayAcronym = $input["gateway-acronym"];
- $gateway->gatewayURL = $input["gateway-url"];
- $gateway->gatewayAdminFirstName = $input["admin-firstname"];
- $gateway->gatewayAdminLastName = $input["admin-lastname"];
- $gateway->identityServerUserName = $input["admin-username"];
- $gateway->identityServerPasswordToken = $input["admin-password"];
- $gateway->reviewProposalDescription = $input["project-details"];
- $gateway->gatewayPublicAbstract - $input["public-project-description"];
+ $gateway = new Gateway( $inputs);
+ $gateway->gatewayId = $inputs["gateway-name"];
+ $gateway->gatewayApprovalStatus = GatewayApprovalStatus::REQUESTED;
+ $gateway->domain = $inputs["domain"];
+ $gateway->gatewayName = $inputs["gateway-name"];
+ $gateway->emailAddress = $inputs["email-address"];
+ $gateway->gatewayAcronym = $inputs["gateway-acronym"];
+ $gateway->gatewayURL = $inputs["gateway-url"];
+ $gateway->gatewayAdminFirstName = $inputs["admin-firstname"];
+ $gateway->gatewayAdminLastName = $inputs["admin-lastname"];
+ $gateway->identityServerUserName = $inputs["admin-username"];
+ $gateway->identityServerPasswordToken = $inputs["admin-password"];
+ $gateway->reviewProposalDescription = $inputs["project-details"];
+ $gateway->gatewayPublicAbstract - $inputs["public-project-description"];
return Airavata::addGateway(Session::get('authz-token'), $gateway);
+
+ }
+
+ public static function update_gateway_status( $gatewayId, $status){
+ $gateway = Airavata::getGateway( Session::get('authz-token'), $gatewayId);
+ $gateway->gatewayApprovalStatus = intval( $status);
+
+ if( Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway) ){
+ if( $gateway->gatewayApprovalStatus == GatewayApprovalStatus::APPROVED){
+ if( AdminUtilities::add_tenant( $gateway) ){
+ Adminutilities::update_gateway_status( Input::get("gateway_id"), GatewayApprovalStatus::ACTIVE);
+ }
+ }
+
+ }
+ }
+
+ public static function add_tenant( $gateway){
+ return WSIS::createTenant(1, $gateway->identityServerUserName . "@" . $gateway->domain, $gateway->identityServerPasswordToken, $gateway->emailAddress,$gateway->gatewayAdminFirstName, $gateway->gatewayAdminLastName, $gateway->domain);
}
/**
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4af8a9ad/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 042b31a..171965a 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -507,7 +507,6 @@ class CRUtilities
public static function getAllGateways()
{
-
if (Session::has("super-admin"))
$gateways = Airavata::getAllGateways(Session::get('authz-token'));
else {
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4af8a9ad/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index f9e55d6..a574d21 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -313,7 +313,7 @@ Route::post("admin/create-pwd-token", "AdminController@createPWD");
Route::post("admin/remove-pwd-token", "AdminController@removePWD");
//GatewayProviders
-Route::post("provider/request-gateway", "GatewayController@requestGateway");
+Route::get("provider/request-gateway", "AdminController@requestGateway");
//notices
Route::get("admin/dashboard/notices", "AdminController@noticesView");
@@ -331,6 +331,8 @@ Route::post("notice-seen-ack", "AccountController@noticeSeenAck");
Route::post("admin/add-gateway", "AdminController@addGateway");
Route::get("admin/add-gateway", "AdminController@addGateway");
+Route::get("admin/update-gateway-request", "AdminController@updateGatewayRequest");
+
/*
* Theme Pages Routes
*/
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4af8a9ad/app/views/account/dashboard.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/dashboard.blade.php b/app/views/account/dashboard.blade.php
index c7a9340..917319b 100644
--- a/app/views/account/dashboard.blade.php
+++ b/app/views/account/dashboard.blade.php
@@ -30,17 +30,40 @@
<label class="control-label">Gateway Name</label>
<input type="text" name="gateway-name" class="form-control" required="required"/>
</div>
- <div class="form-group required">
+ <div class="form-group">
<label class="control-label">Gateway Acronym <i>(optional)</i></label>
<input type="text" name="gateway-acronym" class="form-control"/>
</div>
<div class="form-group required">
+ <label class="control-label">Domain</label>
+ <input type="text" name="domain" class="form-control"/>
+ </div>
+
+ <div class="form-group required">
+ <label class="control-label">Gateway URL</label>
+ <input type="text" name="gateway-url" class="form-control"/>
+ </div>
+ <div class="form-group required">
<label class="control-label">Gateway Admin Username</label>
- <input type="text" name="admin-username" class="form-control" required="required"/>
+ <input type="text" name="admin-username" value="{{ Session::get('username') }}" readonly="true" class="form-control" required="required"/>
</div>
<div class="form-group required">
<label class="control-label">Gateway Admin Password</label>
- <input type="text" name="admin-password" class="form-control" required="required"/>
+ <input type="password" name="admin-password" class="form-control" required="required"/>
+ </div>
+ <div class="form-group required">
+ <label class="control-label">Admin Password Confirmation</label>
+ <input type="password" name="admin-password-confirm" class="form-control" required="required"/>
+ </div>
+
+ <div class="form-group required">
+ <label class="control-label">Admin First Name</label>
+ <input type="text" name="admin-firstname" class="form-control" required="required"/>
+ </div>
+
+ <div class="form-group required">
+ <label class="control-label">Admin Last Name</label>
+ <input type="text" name="admin-lastname" class="form-control" required="required"/>
</div>
<div class="form-group required">
<label class="control-label">Gateway Email</label>
@@ -59,6 +82,14 @@
</form>
</div>
</div>
+ @elseif( Session::has("existing-gateway-provider") )
+ @if( Session::get("approvalStatus") == "Requested")
+ <blockquote>Gateway you have request is yet to be approved. Please log back in after sometime.</blockquote>
+ @elseif( Session::get("approvalStatus") == "Denied")
+ <div class="well alert alert-danger">Unfortunately, Your Request has been denied at this moment.</div>
+ @else
+ <blockquote>Download Credentials | Get Started with your PGA View</blockquote>
+ @endif
@elseif( Session::has('authorized-user') || Session::has('admin') || Session::has('admin-read-only') )
<div class="row text-center breathing-space">
<h1>Let's get started!</h1>
@@ -283,45 +314,6 @@
$(".add-tenant").slideDown();
});
- $("#add-tenant-form").submit(function (event) {
- event.preventDefault();
- event.stopPropagation();
- var formData = $("#add-tenant-form").serialize();
- $("#add-gateway-loading").modal("show");
- $(".loading-gif").removeClass("hide");
- $.ajax({
- type: "POST",
- data: formData,
- url: '{{ URL::to("/") }}/admin/add-gateway',
- success: function (data) {
- if( data.gateway == $(".gatewayName").val() ){
- $(".gateway-success").html("Gateway has been added. The page will be reloaded in a moment.").removeClass("hide");
- setTimeout( function(){
- location.reload();
- }, 2000);
- }
- else if( data == 0){
- $(".gateway-error").html( "An unknown error occurred while trying to create the gateway.")
- .removeClass("hide");
- }
- else{
- errors = data;
- $(".gateway-error").html("").removeClass("hide");
- for( input in data)
- {
- $(".gateway-error").append(" -- " + input + " : " + data[input] + "<br/><br/>");
- }
- }
- },
- error: function( data){
- var error = $.parseJSON( data.responseText);
- $(".gateway-error").html(error.error.message).removeClass("hide");
- }
- }).complete(function () {
- $("#add-gateway-loading").modal("hide");
- $(".loading-gif").addClass("hide");
- });
- });
</script>
@stop
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4af8a9ad/app/views/admin/manage-gateway.blade.php
----------------------------------------------------------------------
diff --git a/app/views/admin/manage-gateway.blade.php b/app/views/admin/manage-gateway.blade.php
index 28b7a79..4198db3 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -66,19 +66,32 @@
<div class="col-md-12">
<h3>Gateway Requests</h3>
<table class="table table-striped table-bordered">
- <th>
+ <thead>
<tr>
- <td>Gateway Name</td>
- <td>Admin Name</td>
- <td>Gateway URL</td>
- <td>Project Details</td>
- <td>Status</td>
+ <th>Gateway Name</th>
+ <th>Admin Name</th>
+ <th>Gateway URL</th>
+ <th>Project Details</th>
+ <th>Project Abstract</th>
+ <th>Actions</th>
</tr>
- </th>
+ </thead>
<tbody>
- <!-- foreach code -->
+ @foreach( $gateways as $indexGP => $gp )
+ @if( $gp->gatewayApprovalStatus == 0)
<tr>
+ <td>{{$gp->gatewayName }}</td>
+ <td>{{ $gp->gatewayAdminFirstName }} {{ $gp->gatewayAdminLastName }} </td>
+ <td>{{ $gp->gatewayURL }}</td>
+ <td>{{ $gp->reviewProposalDescription}}</td>
+ <td>{{ $gp->gatewayPublicAbstract}}</td>
+ <td>
+ <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gp->gatewayId}}&status=1"><input type="button" class="btn btn-primary" value="Approve"/></a>
+ <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gp->gatewayId}}&status=3"><input type="button" class="btn btn-danger" value="Deny"/></a>
+ </td>
</tr>
+ @endif
+ @endforeach
<!-- foreach code ends -->
</tbody>
</table>
@@ -86,6 +99,7 @@
</div>
<div class="panel-group super-admin-gateways-view" id="accordion1">
+ <h3>Approved Gateways</h3>
@foreach( $gateways as $indexGP => $gp )
@include('partials/gateway-preferences-block', array("gp" => $gp, "accName" => "accordion1"))
@endforeach