Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ask before deleting hardware token #1937

Merged
merged 4 commits into from Nov 21, 2019

Conversation

@debianis
Copy link
Contributor

debianis commented Nov 19, 2019

fixes this issue - if user wants to delete token which is hardwaretype, he will be asked.

Closes #954

fixes this issue - if user wants to delete token which is hardwaretype, he will be asked.

Closes #954
@codecov

This comment has been minimized.

Copy link

codecov bot commented Nov 19, 2019

Codecov Report

Merging #1937 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1937   +/-   ##
=======================================
  Coverage   97.13%   97.13%           
=======================================
  Files         153      153           
  Lines       18556    18556           
=======================================
  Hits        18024    18024           
  Misses        532      532

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 521f702...e2d6549. Read the comment docs.

final fix

Closes #954
@debianis debianis force-pushed the debianis:954/ask_delete_hardware_token branch from 05ab07d to e0b28aa Nov 19, 2019
Copy link
Contributor

NuvandaPV left a comment

Thank you for your pull request :-) I have made a few comments.

};
};

$scope.deleteToken = function(){

This comment has been minimized.

Copy link
@NuvandaPV

NuvandaPV Nov 20, 2019

Contributor

This function is pointless. $scope.delete() already does the exact same thing. Please use $scope.delete().


$scope.deleteToken = function(){
TokenFactory.delete($scope.tokenSerial, $scope.return_to,
function (data) {

This comment has been minimized.

Copy link
@NuvandaPV

NuvandaPV Nov 20, 2019

Contributor

Explanation: TokenFactory.delete only takes two parameters. The third parameter you have added here is ignored completely. This makes your new function identical to $scope.delete().

$scope.delete = function () {
TokenFactory.delete($scope.tokenSerial, $scope.return_to);
$scope.deleteTokenAsk = function() {
$('#dialogTokenDelete').modal();

This comment has been minimized.

Copy link
@NuvandaPV

NuvandaPV Nov 20, 2019

Contributor

I think this line needs to be removed. My suspicion is, that is would cause the modal to always show, even if the token is not a hardware token.

This comment has been minimized.

Copy link
@debianis

debianis Nov 21, 2019

Author Contributor

i tested it in venv and it does work as intended.

$('#dialogTokenDelete').modal();
var tokenType = $scope.token.info.tokenkind;
if (tokenType == "hardware"){
$('#dialogTokenDelete').modal();

This comment has been minimized.

Copy link
@NuvandaPV

NuvandaPV Nov 20, 2019

Contributor

This looks good, but please fix the indentation. It is really hard to read otherwise. the code should look something like this:

if (condition) {
    doSomething();
} else {
    doSomethingElse();
}
if (tokenType == "hardware"){
$('#dialogTokenDelete').modal();
} else {
TokenFactory.delete($scope.tokenSerial, $scope.return_to,

This comment has been minimized.

Copy link
@NuvandaPV

NuvandaPV Nov 20, 2019

Contributor

The third parameter here does not do anything (see explanation below). What are you trying to do here? We already have a function $scope.delete() that calls TokenFactory.delete() with the correct parameters. Unless there is a specific reason why you need the extra code, please just call $scope.delete().

<button type="button"
class="btn btn-danger"
data-dismiss="modal"
ng-click="deleteToken()">

This comment has been minimized.

Copy link
@NuvandaPV

NuvandaPV Nov 20, 2019

Contributor

As stated above, there is not need for a new function deleteToken(), as that is what delete() already does. Please refactor this to use delete().

deleted the delete token function and rearranged the indentation.
@debianis debianis requested a review from NuvandaPV Nov 21, 2019
@NuvandaPV NuvandaPV merged commit a8dd0b5 into privacyidea:master Nov 21, 2019
3 checks passed
3 checks passed
codecov/patch Coverage not affected when comparing 521f702...e2d6549
Details
codecov/project 97.13% remains the same compared to 521f702
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.