AIRAVATA-2408 Fixes to user profile editor
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/3f99eb64 Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/3f99eb64 Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/3f99eb64 Branch: refs/heads/develop Commit: 3f99eb644531b0904daf084e74543af6b32d2cfb Parents: 31b1ca8 Author: Marcus Christie <[email protected]> Authored: Sun Jun 11 16:25:02 2017 -0400 Committer: Marcus Christie <[email protected]> Committed: Sun Jun 11 16:25:02 2017 -0400 ---------------------------------------------------------------------- app/controllers/UserSettingsController.php | 11 +- app/libraries/Airavata/API/Airavata.php | 466 +------------------ app/views/account/user-profile.blade.php | 43 +- app/views/layout/basic.blade.php | 2 +- .../user-profile-phone-template.blade.php | 9 - 5 files changed, 32 insertions(+), 499 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3f99eb64/app/controllers/UserSettingsController.php ---------------------------------------------------------------------- diff --git a/app/controllers/UserSettingsController.php b/app/controllers/UserSettingsController.php index 7b93f19..0cd69ec 100644 --- a/app/controllers/UserSettingsController.php +++ b/app/controllers/UserSettingsController.php @@ -201,16 +201,9 @@ class UserSettingsController extends BaseController $userProfile = UserProfileUtilities::get_user_profile($username); // Copy data from form to $userProfile object and update - $userProfile->userName = Input::get("userName"); + $userProfile->firstName = Input::get("firstName"); + $userProfile->lastName = Input::get("lastName"); $userProfile->homeOrganization = Input::get("homeOrganization"); - $userProfile->country = Input::get("country"); - if (Input::has("phones")) { - $phones = Input::get("phones"); - // Filter out empty phone numbers - $userProfile->phones = array_filter($phones, function($phone) { - return trim($phone) !== ""; - }); - } try { UserProfileUtilities::update_user_profile($userProfile); // Now update the UserProfile in the Session http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3f99eb64/app/libraries/Airavata/API/Airavata.php ---------------------------------------------------------------------- diff --git a/app/libraries/Airavata/API/Airavata.php b/app/libraries/Airavata/API/Airavata.php index e1032be..9c20f39 100644 --- a/app/libraries/Airavata/API/Airavata.php +++ b/app/libraries/Airavata/API/Airavata.php @@ -4139,6 +4139,12 @@ interface AiravataIf { * * Externally assertable unique identifier. SAML (primarly in higher education, academic) tends to keep * * user name less opaque. OpenID Connect maintains them to be opaque. * * + * * firstName, middleName, lastName: + * * First and Last names as assertede by the user + * * + * * namePrefix, nameSuffix: + * * prefix and suffix to the users name as asserted by the user + * * * * emails: * * Email identifier are Verified, REQUIRED and MULTIVALUED * * @@ -4200,68 +4206,7 @@ interface AiravataIf { public function getAllUserProfilesInGateway(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $offset, $limit); /** * @param \Airavata\Model\Security\AuthzToken $authzToken - * @param string $userName - * @param string $gatewayId - * @return \Airavata\Model\User\UserProfile * A structure holding the user profile and its child models. - * * - * * Notes: - * * The model does not include passwords as it is assumed an external identity provider is used to authenticate user. - * * References: - * * NSF Demographic Information - http://www.nsf.gov/pubs/2000/00form1225/00form1225.doc - * * LDAP Schema - https://tools.ietf.org/html/rfc4519 - * * SCIM 2.0 - https://tools.ietf.org/html/rfc7643 - * * - * * userModelVersion: - * * Version number of profile - * * - * * airavataInternalUserId: - * * internal to Airavata, not intended to be used outside of the Airavata platform or possibly by gateways - * * (that is, never shown to users), never reassigned, REQUIRED - * * - * * userId: - * * Externally assertable unique identifier. SAML (primarly in higher education, academic) tends to keep - * * user name less opaque. OpenID Connect maintains them to be opaque. - * * - * * emails: - * * Email identifier are Verified, REQUIRED and MULTIVALUED - * * - * * userName: - * * Name-based identifiers can be multivalues. To keep it simple, Airavata will make it a string. - * * In the future these can be enumerated as: - * * Official name (as asserted possibly by some external identity provider) - * * Prefered name (as asserted or suggested by user directly) - * * Components: - * * givenName - * * surname (familyName) - * * displayName (often asserted by user to handle things like middle names, suffix, prefix, and the like) - * * - * * orcidId: ORCID ID - http://orcid.org/about/what-is-orcid) - * * - * * phones: Telephone MULTIVALUED - * * - * * country: Country of Residance - * * - * * nationality Countries of citizenship - * * - * * comments: - * * Free-form information (treated as opaque by Airavata and simply passed to resource). - * * - * * labeledURI: - * * Google Scholar, Web of Science, ACS, e.t.c - * * - * * timeZone: - * * Userâs preferred timezone - IANA Timezone Databases - http://www.iana.org/time-zones. - * * - * - * @throws \Airavata\API\Error\InvalidRequestException - * @throws \Airavata\API\Error\AiravataClientException - * @throws \Airavata\API\Error\AiravataSystemException - * @throws \Airavata\API\Error\AuthorizationException - */ - public function getUserProfileByName(\Airavata\Model\Security\AuthzToken $authzToken, $userName, $gatewayId); - /** - * @param \Airavata\Model\Security\AuthzToken $authzToken - * @param string $userName + * @param string $userId * @param string $gatewayId * @return bool * @throws \Airavata\API\Error\InvalidRequestException @@ -4269,7 +4214,7 @@ interface AiravataIf { * @throws \Airavata\API\Error\AiravataSystemException * @throws \Airavata\API\Error\AuthorizationException */ - public function doesUserProfileExist(\Airavata\Model\Security\AuthzToken $authzToken, $userName, $gatewayId); + public function doesUserProfileExist(\Airavata\Model\Security\AuthzToken $authzToken, $userId, $gatewayId); } class AiravataClient implements \Airavata\API\AiravataIf { @@ -15553,82 +15498,17 @@ class AiravataClient implements \Airavata\API\AiravataIf { throw new \Exception("getAllUserProfilesInGateway failed: unknown result"); } - public function getUserProfileByName(\Airavata\Model\Security\AuthzToken $authzToken, $userName, $gatewayId) - { - $this->send_getUserProfileByName($authzToken, $userName, $gatewayId); - return $this->recv_getUserProfileByName(); - } - - public function send_getUserProfileByName(\Airavata\Model\Security\AuthzToken $authzToken, $userName, $gatewayId) - { - $args = new \Airavata\API\Airavata_getUserProfileByName_args(); - $args->authzToken = $authzToken; - $args->userName = $userName; - $args->gatewayId = $gatewayId; - $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); - if ($bin_accel) - { - thrift_protocol_write_binary($this->output_, 'getUserProfileByName', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); - } - else - { - $this->output_->writeMessageBegin('getUserProfileByName', TMessageType::CALL, $this->seqid_); - $args->write($this->output_); - $this->output_->writeMessageEnd(); - $this->output_->getTransport()->flush(); - } - } - - public function recv_getUserProfileByName() - { - $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); - if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Airavata\API\Airavata_getUserProfileByName_result', $this->input_->isStrictRead()); - else - { - $rseqid = 0; - $fname = null; - $mtype = 0; - - $this->input_->readMessageBegin($fname, $mtype, $rseqid); - if ($mtype == TMessageType::EXCEPTION) { - $x = new TApplicationException(); - $x->read($this->input_); - $this->input_->readMessageEnd(); - throw $x; - } - $result = new \Airavata\API\Airavata_getUserProfileByName_result(); - $result->read($this->input_); - $this->input_->readMessageEnd(); - } - if ($result->success !== null) { - return $result->success; - } - if ($result->ire !== null) { - throw $result->ire; - } - if ($result->ace !== null) { - throw $result->ace; - } - if ($result->ase !== null) { - throw $result->ase; - } - if ($result->ae !== null) { - throw $result->ae; - } - throw new \Exception("getUserProfileByName failed: unknown result"); - } - - public function doesUserProfileExist(\Airavata\Model\Security\AuthzToken $authzToken, $userName, $gatewayId) + public function doesUserProfileExist(\Airavata\Model\Security\AuthzToken $authzToken, $userId, $gatewayId) { - $this->send_doesUserProfileExist($authzToken, $userName, $gatewayId); + $this->send_doesUserProfileExist($authzToken, $userId, $gatewayId); return $this->recv_doesUserProfileExist(); } - public function send_doesUserProfileExist(\Airavata\Model\Security\AuthzToken $authzToken, $userName, $gatewayId) + public function send_doesUserProfileExist(\Airavata\Model\Security\AuthzToken $authzToken, $userId, $gatewayId) { $args = new \Airavata\API\Airavata_doesUserProfileExist_args(); $args->authzToken = $authzToken; - $args->userName = $userName; + $args->userId = $userId; $args->gatewayId = $gatewayId; $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); if ($bin_accel) @@ -69053,312 +68933,6 @@ class Airavata_getAllUserProfilesInGateway_result { } -class Airavata_getUserProfileByName_args { - static $_TSPEC; - - /** - * @var \Airavata\Model\Security\AuthzToken - */ - public $authzToken = null; - /** - * @var string - */ - public $userName = null; - /** - * @var string - */ - public $gatewayId = null; - - public function __construct($vals=null) { - if (!isset(self::$_TSPEC)) { - self::$_TSPEC = array( - 1 => array( - 'var' => 'authzToken', - 'type' => TType::STRUCT, - 'class' => '\Airavata\Model\Security\AuthzToken', - ), - 2 => array( - 'var' => 'userName', - 'type' => TType::STRING, - ), - 3 => array( - 'var' => 'gatewayId', - 'type' => TType::STRING, - ), - ); - } - if (is_array($vals)) { - if (isset($vals['authzToken'])) { - $this->authzToken = $vals['authzToken']; - } - if (isset($vals['userName'])) { - $this->userName = $vals['userName']; - } - if (isset($vals['gatewayId'])) { - $this->gatewayId = $vals['gatewayId']; - } - } - } - - public function getName() { - return 'Airavata_getUserProfileByName_args'; - } - - public function read($input) - { - $xfer = 0; - $fname = null; - $ftype = 0; - $fid = 0; - $xfer += $input->readStructBegin($fname); - while (true) - { - $xfer += $input->readFieldBegin($fname, $ftype, $fid); - if ($ftype == TType::STOP) { - break; - } - switch ($fid) - { - case 1: - if ($ftype == TType::STRUCT) { - $this->authzToken = new \Airavata\Model\Security\AuthzToken(); - $xfer += $this->authzToken->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - case 2: - if ($ftype == TType::STRING) { - $xfer += $input->readString($this->userName); - } else { - $xfer += $input->skip($ftype); - } - break; - case 3: - if ($ftype == TType::STRING) { - $xfer += $input->readString($this->gatewayId); - } else { - $xfer += $input->skip($ftype); - } - break; - default: - $xfer += $input->skip($ftype); - break; - } - $xfer += $input->readFieldEnd(); - } - $xfer += $input->readStructEnd(); - return $xfer; - } - - public function write($output) { - $xfer = 0; - $xfer += $output->writeStructBegin('Airavata_getUserProfileByName_args'); - if ($this->authzToken !== null) { - if (!is_object($this->authzToken)) { - throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); - } - $xfer += $output->writeFieldBegin('authzToken', TType::STRUCT, 1); - $xfer += $this->authzToken->write($output); - $xfer += $output->writeFieldEnd(); - } - if ($this->userName !== null) { - $xfer += $output->writeFieldBegin('userName', TType::STRING, 2); - $xfer += $output->writeString($this->userName); - $xfer += $output->writeFieldEnd(); - } - if ($this->gatewayId !== null) { - $xfer += $output->writeFieldBegin('gatewayId', TType::STRING, 3); - $xfer += $output->writeString($this->gatewayId); - $xfer += $output->writeFieldEnd(); - } - $xfer += $output->writeFieldStop(); - $xfer += $output->writeStructEnd(); - return $xfer; - } - -} - -class Airavata_getUserProfileByName_result { - static $_TSPEC; - - /** - * @var \Airavata\Model\User\UserProfile - */ - public $success = null; - /** - * @var \Airavata\API\Error\InvalidRequestException - */ - public $ire = null; - /** - * @var \Airavata\API\Error\AiravataClientException - */ - public $ace = null; - /** - * @var \Airavata\API\Error\AiravataSystemException - */ - public $ase = null; - /** - * @var \Airavata\API\Error\AuthorizationException - */ - public $ae = null; - - public function __construct($vals=null) { - if (!isset(self::$_TSPEC)) { - self::$_TSPEC = array( - 0 => array( - 'var' => 'success', - 'type' => TType::STRUCT, - 'class' => '\Airavata\Model\User\UserProfile', - ), - 1 => array( - 'var' => 'ire', - 'type' => TType::STRUCT, - 'class' => '\Airavata\API\Error\InvalidRequestException', - ), - 2 => array( - 'var' => 'ace', - 'type' => TType::STRUCT, - 'class' => '\Airavata\API\Error\AiravataClientException', - ), - 3 => array( - 'var' => 'ase', - 'type' => TType::STRUCT, - 'class' => '\Airavata\API\Error\AiravataSystemException', - ), - 4 => array( - 'var' => 'ae', - 'type' => TType::STRUCT, - 'class' => '\Airavata\API\Error\AuthorizationException', - ), - ); - } - if (is_array($vals)) { - if (isset($vals['success'])) { - $this->success = $vals['success']; - } - if (isset($vals['ire'])) { - $this->ire = $vals['ire']; - } - if (isset($vals['ace'])) { - $this->ace = $vals['ace']; - } - if (isset($vals['ase'])) { - $this->ase = $vals['ase']; - } - if (isset($vals['ae'])) { - $this->ae = $vals['ae']; - } - } - } - - public function getName() { - return 'Airavata_getUserProfileByName_result'; - } - - public function read($input) - { - $xfer = 0; - $fname = null; - $ftype = 0; - $fid = 0; - $xfer += $input->readStructBegin($fname); - while (true) - { - $xfer += $input->readFieldBegin($fname, $ftype, $fid); - if ($ftype == TType::STOP) { - break; - } - switch ($fid) - { - case 0: - if ($ftype == TType::STRUCT) { - $this->success = new \Airavata\Model\User\UserProfile(); - $xfer += $this->success->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - case 1: - if ($ftype == TType::STRUCT) { - $this->ire = new \Airavata\API\Error\InvalidRequestException(); - $xfer += $this->ire->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - case 2: - if ($ftype == TType::STRUCT) { - $this->ace = new \Airavata\API\Error\AiravataClientException(); - $xfer += $this->ace->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - case 3: - if ($ftype == TType::STRUCT) { - $this->ase = new \Airavata\API\Error\AiravataSystemException(); - $xfer += $this->ase->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - case 4: - if ($ftype == TType::STRUCT) { - $this->ae = new \Airavata\API\Error\AuthorizationException(); - $xfer += $this->ae->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - default: - $xfer += $input->skip($ftype); - break; - } - $xfer += $input->readFieldEnd(); - } - $xfer += $input->readStructEnd(); - return $xfer; - } - - public function write($output) { - $xfer = 0; - $xfer += $output->writeStructBegin('Airavata_getUserProfileByName_result'); - if ($this->success !== null) { - if (!is_object($this->success)) { - throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); - } - $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0); - $xfer += $this->success->write($output); - $xfer += $output->writeFieldEnd(); - } - if ($this->ire !== null) { - $xfer += $output->writeFieldBegin('ire', TType::STRUCT, 1); - $xfer += $this->ire->write($output); - $xfer += $output->writeFieldEnd(); - } - if ($this->ace !== null) { - $xfer += $output->writeFieldBegin('ace', TType::STRUCT, 2); - $xfer += $this->ace->write($output); - $xfer += $output->writeFieldEnd(); - } - if ($this->ase !== null) { - $xfer += $output->writeFieldBegin('ase', TType::STRUCT, 3); - $xfer += $this->ase->write($output); - $xfer += $output->writeFieldEnd(); - } - if ($this->ae !== null) { - $xfer += $output->writeFieldBegin('ae', TType::STRUCT, 4); - $xfer += $this->ae->write($output); - $xfer += $output->writeFieldEnd(); - } - $xfer += $output->writeFieldStop(); - $xfer += $output->writeStructEnd(); - return $xfer; - } - -} - class Airavata_doesUserProfileExist_args { static $_TSPEC; @@ -69369,7 +68943,7 @@ class Airavata_doesUserProfileExist_args { /** * @var string */ - public $userName = null; + public $userId = null; /** * @var string */ @@ -69384,7 +68958,7 @@ class Airavata_doesUserProfileExist_args { 'class' => '\Airavata\Model\Security\AuthzToken', ), 2 => array( - 'var' => 'userName', + 'var' => 'userId', 'type' => TType::STRING, ), 3 => array( @@ -69397,8 +68971,8 @@ class Airavata_doesUserProfileExist_args { if (isset($vals['authzToken'])) { $this->authzToken = $vals['authzToken']; } - if (isset($vals['userName'])) { - $this->userName = $vals['userName']; + if (isset($vals['userId'])) { + $this->userId = $vals['userId']; } if (isset($vals['gatewayId'])) { $this->gatewayId = $vals['gatewayId']; @@ -69435,7 +69009,7 @@ class Airavata_doesUserProfileExist_args { break; case 2: if ($ftype == TType::STRING) { - $xfer += $input->readString($this->userName); + $xfer += $input->readString($this->userId); } else { $xfer += $input->skip($ftype); } @@ -69468,9 +69042,9 @@ class Airavata_doesUserProfileExist_args { $xfer += $this->authzToken->write($output); $xfer += $output->writeFieldEnd(); } - if ($this->userName !== null) { - $xfer += $output->writeFieldBegin('userName', TType::STRING, 2); - $xfer += $output->writeString($this->userName); + if ($this->userId !== null) { + $xfer += $output->writeFieldBegin('userId', TType::STRING, 2); + $xfer += $output->writeString($this->userId); $xfer += $output->writeFieldEnd(); } if ($this->gatewayId !== null) { http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3f99eb64/app/views/account/user-profile.blade.php ---------------------------------------------------------------------- diff --git a/app/views/account/user-profile.blade.php b/app/views/account/user-profile.blade.php index 202284a..09bea45 100644 --- a/app/views/account/user-profile.blade.php +++ b/app/views/account/user-profile.blade.php @@ -42,10 +42,16 @@ <p class="form-control-static">{{{ $userProfile->emails[0] }}}</p> </div> <div class="form-group required"> - <label class="control-label">Name</label> - <div><input class="form-control" id="userName" maxlength="50" name="userName" + <label class="control-label">First Name</label> + <div><input class="form-control" id="firstName" maxlength="50" name="firstName" placeholder="Name" type="text" - value="{{{ $userProfile->userName }}}"/></div> + value="{{{ $userProfile->firstName }}}"/></div> + </div> + <div class="form-group required"> + <label class="control-label">Last Name</label> + <div><input class="form-control" id="lastName" maxlength="50" name="lastName" + placeholder="Name" type="text" + value="{{{ $userProfile->lastName }}}"/></div> </div> <div class="form-group"> <label class="control-label">Organization</label> @@ -54,41 +60,10 @@ value="{{{ $userProfile->homeOrganization }}}"/> </div> </div> - <div class="form-group"> - <label class="control-label">Country</label> - <div><input class="form-control" id="country" name="country" - placeholder="Country" type="text" - value="{{{ $userProfile->country }}}"/> - </div> - </div> - <div class="form-group"> - <label class="control-label">Phone Numbers</label> - @foreach ($userProfile->phones as $phone) - @include('partials/user-profile-phone-template', array('phone' => $phone)) - @endforeach - <button id="add-phone-button" class="btn btn-default" type="button">Add Phone</button> - </div> <input name="update" type="submit" class="btn btn-primary btn-block" value="Update"> </form> </div> -<div id="new-phone-template" class="hidden"> - @include('partials/user-profile-phone-template', array('phone' => '')) -</div> - -@stop - -@section('scripts') -@parent -<script> - - $('#add-phone-button').click(function(e){ - $(this).before($('#new-phone-template').html()); - }); - $(document).on('click', '.delete-phone-button', function(e){ - $(this).closest('.input-group').remove(); - }); -</script> @stop http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3f99eb64/app/views/layout/basic.blade.php ---------------------------------------------------------------------- diff --git a/app/views/layout/basic.blade.php b/app/views/layout/basic.blade.php index ad833b4..7561252 100755 --- a/app/views/layout/basic.blade.php +++ b/app/views/layout/basic.blade.php @@ -31,7 +31,7 @@ $title = Session::get("portal-title"); @if(Session::has("user-profile")) <script> var email = {{ json_encode(Session::get("user-profile")->emails[0]) }}; -var fullName = {{ json_encode(Session::get("user-profile")->userName) }}; +var fullName = {{ json_encode(Session::get("user-profile")->firstName . " " . Session::get("user-profile")->lastName) }}; </script> @endif http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3f99eb64/app/views/partials/user-profile-phone-template.blade.php ---------------------------------------------------------------------- diff --git a/app/views/partials/user-profile-phone-template.blade.php b/app/views/partials/user-profile-phone-template.blade.php deleted file mode 100644 index 6843f57..0000000 --- a/app/views/partials/user-profile-phone-template.blade.php +++ /dev/null @@ -1,9 +0,0 @@ - -<div class="input-group"> - <input class="form-control" name="phones[]" - placeholder="Phone number" type="text" - value="{{{ $phone or '' }}}" /> - <span class="input-group-btn"> - <button class="btn btn-default delete-phone-button" type="button">Delete</button> - </span> -</div>
