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

Conversation

debianis
Copy link
Contributor

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 privacyidea#954
@codecov
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.

@debianis debianis force-pushed the 954/ask_delete_hardware_token branch from 05ab07d to e0b28aa Compare November 19, 2019 14:16
Copy link

@jp-hoehmann jp-hoehmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

};
};

$scope.deleteToken = function(){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@jp-hoehmann jp-hoehmann merged commit a8dd0b5 into privacyidea:master Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ask before deleting hardware tokens
2 participants