Added copy 2 clipboard feature on OAUTH2 Client Data

Change-Id: Ie6ec98a491ff543c71e2f2c396b5653a2917faea
Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
smarcet 2020-02-29 01:06:03 -03:00
parent 0a23b02e4b
commit 48e7b56d9a
8 changed files with 98 additions and 17 deletions

1
.gitignore vendored
View File

@ -33,6 +33,7 @@ public/assets/css/index.css
/public/assets/sweetalert2/
/public/assets/urijs
/public/assets/uri.js
/public/assets/clipboard-copy-element/
_intellij_phpdebug_validator.php
/public/assets/chosen-js
/public/assets/moment

View File

@ -1184,7 +1184,7 @@ final class TokenService extends AbstractService implements ITokenService
foreach($client->getRefreshTokens() as $rt)
{
$this->markRefreshTokenAsRevoked($rt);
$this->markRefreshTokenAsRevoked($rt->getValue());
}
$client->removeAllAccessTokens();

46
package-lock.json generated
View File

@ -4,6 +4,11 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@github/clipboard-copy-element": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@github/clipboard-copy-element/-/clipboard-copy-element-1.1.2.tgz",
"integrity": "sha512-L6CMrcA5we0udafvoSuRCE/Ci/3xrLWKYRGup2IlhxF771bQYsQ2EB1of182pI8ZWM4oxgwzu37+igMeoZjN/A=="
},
"@gulp-sourcemaps/map-sources": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz",
@ -3828,7 +3833,8 @@
},
"ansi-regex": {
"version": "2.1.1",
"bundled": true
"bundled": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -3846,11 +3852,13 @@
},
"balanced-match": {
"version": "1.0.0",
"bundled": true
"bundled": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -3863,15 +3871,18 @@
},
"code-point-at": {
"version": "1.1.0",
"bundled": true
"bundled": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true
"bundled": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true
"bundled": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -3974,7 +3985,8 @@
},
"inherits": {
"version": "2.0.3",
"bundled": true
"bundled": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -3984,6 +3996,7 @@
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -3996,17 +4009,20 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"bundled": true
"bundled": true,
"optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -4023,6 +4039,7 @@
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -4101,7 +4118,8 @@
},
"number-is-nan": {
"version": "1.0.1",
"bundled": true
"bundled": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -4111,6 +4129,7 @@
"once": {
"version": "1.4.0",
"bundled": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -4186,7 +4205,8 @@
},
"safe-buffer": {
"version": "5.1.2",
"bundled": true
"bundled": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -4216,6 +4236,7 @@
"string-width": {
"version": "1.0.2",
"bundled": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -4233,6 +4254,7 @@
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -4271,11 +4293,13 @@
},
"wrappy": {
"version": "1.0.2",
"bundled": true
"bundled": true,
"optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true
"bundled": true,
"optional": true
}
}
},

View File

@ -28,6 +28,7 @@
"url-loader": "^0.6.2"
},
"dependencies": {
"@github/clipboard-copy-element": "^1.1.2",
"bootstrap": "^3.3.7",
"bootstrap-datepicker": "^1.8.0",
"bootstrap-sass": "^3.0.0",

View File

@ -339,4 +339,10 @@ span.help-block::before {
margin-bottom: 10px;
font-size: 12px;
color: #aaa;
}
.input-group-button {
width: 1%;
vertical-align: middle;
display:table-cell;
}

View File

@ -123,7 +123,7 @@ jQuery(document).ready(function($){
timeout:60000,
success: function (data,textStatus,jqXHR) {
//load data...
$('#client_secret').text(data.client_secret);
$('#client_secret > :input').val(data.client_secret);
//$('#client_secret_expiration_date').text(data.new_expiration_date.date);
//clean token UI
$('#table-access-tokens').remove();

View File

@ -8,7 +8,26 @@
<div class="row">
<div class="col-md-12">
<label for="client_id" class="label-client-secret">Client ID</label>
<span id="client_id">{!! $client->client_id !!}</span>
<div id="client_id" class="input-group">
<input type="text" id="client_id_text" class="form-control input-monospace input-sm"
data-autoselect=""
value="{!! $client->client_id !!}"
aria-label="Client Id"
readonly="">
<div class="input-group-button">
<clipboard-copy
for="client_id_text"
aria-label="Copy to clipboard"
class="btn btn-sm"
tabindex="0" role="button">
<svg class="octicon octicon-clippy" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true">
<path fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"></path>
</svg>
<span class="notice" hidden>Copied!<span>
</clipboard-copy>
</div>
</div>
</div>
</div>
@if($client->client_type == OAuth2\Models\IClient::ClientType_Confidential)
@ -16,10 +35,29 @@
<div class="row">
<div class="col-md-12">
<label for="client_secret" class="label-client-secret">Client Secret</label>
<span id="client_secret">{!! $client->client_secret !!}</span>
@if ($client->isOwner(Auth::user()))
{!! HTML::link(URL::action("Api\\ClientApiController@regenerateClientSecret",array("id"=>$client->id)),'Regenerate',array('class'=>'btn btn-default btn-md active regenerate-client-secret','title'=>'Regenerates Client Secret')) !!}
{!! HTML::link(URL::action("Api\\ClientApiController@regenerateClientSecret",array("id"=>$client->id)),'Regenerate',array('class'=>'btn btn-default btn-xs active regenerate-client-secret','title'=>'Regenerates Client Secret')) !!}
@endif
<div id="client_secret" class="input-group">
<input type="text" class="form-control input-monospace input-sm"
data-autoselect=""
value="{!! $client->client_secret !!}"
aria-label="Client Secret"
id="client_secret_text"
readonly="">
<div class="input-group-button">
<clipboard-copy
for="client_secret_text"
aria-label="Copy to clipboard"
class="btn btn-sm"
tabindex="0" role="button">
<svg class="octicon octicon-clippy" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true">
<path fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"></path>
</svg>
<span class="notice" hidden>Copied!<span>
</clipboard-copy>
</div>
</div>
</div>
</div>
@endif
@ -141,5 +179,15 @@
</div>
@section('scripts')
{!! HTML::script('assets/js/oauth2/profile/edit-client-data.js') !!}
{!! HTML::script('assets/clipboard-copy-element/index.umd.js')!!}
{!! HTML::script('assets/js/oauth2/profile/edit-client-data.js') !!}'
<script>
document.addEventListener('clipboard-copy', function(event) {
const notice = event.target.querySelector('.notice')
notice.hidden = false
setTimeout(function() {
notice.hidden = true
}, 1000)
})
</script>
@append

View File

@ -41,6 +41,7 @@ var plugins = [
{from: './node_modules/urijs/src', to: 'urijs'},
{from: './node_modules/chosen-js', to: 'chosen-js'},
{from: './node_modules/moment', to: 'moment'},
{from: './node_modules/@github/clipboard-copy-element/dist', to: 'clipboard-copy-element'},
],
{copyUnmodified: false}
),