Skip to content

Commit

Permalink
#166 delete supports connections which have been created with and wit…
Browse files Browse the repository at this point in the history
…hout the DIDentity app

Signed-off-by: Karol Bakas <karol.bakas@fau.de>
  • Loading branch information
Idontker committed Jun 26, 2022
1 parent 8bd9662 commit 53fe4a9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public class ConnectionController {
}

@PostMapping(path = "/remove")
public @ResponseBody ResponseEntity<String> remove(@RequestParam Integer id,
public @ResponseBody ResponseEntity<String> remove(
@RequestParam String connectionId,
@RequestParam(required = false) String authorization) {

if (authenticationService.authentication(authorization) == false) {
return authenticationService.getError();
}

return diConnectionService.remove(id);
return diConnectionService.remove(connectionId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
@Repository
public interface UserRepository extends CrudRepository<User, Integer> {
public Optional<User> findByEmail(String email);
public Optional<User> findByconnectionId(String connectionId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,15 @@ public ResponseEntity<String> remove(Integer id) {
}
}

public ResponseEntity<String> remove(String connectionId) {
Optional<User> user = userRepository.findByconnectionId(connectionId);
if (user.isPresent()) {
return remove(user.get());
} else {
return removeByConnectionId(connectionId);
}
}

public ResponseEntity<String> remove(User user) {
// TODO: revoking credentials and proofs is not implemented within the lissi
// universe
Expand All @@ -259,4 +268,13 @@ private ResponseEntity<String> remove(User user, boolean removeCreds, boolean re
return ResponseEntity.status(200).body("Successfully removed connection.");
}

public ResponseEntity<String> removeByConnectionId(String connectionId) {
ResponseEntity<String> response = lissiApiService.removeConnection(connectionId, false,
false);
if (response == null) {
return ResponseEntity.status(500).body("Could not remove the connection on the lissi legder.");
}
return ResponseEntity.status(200).body("Successfully removed connection.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ export class DIOverviewComponent implements OnInit {
}

deleteDiConnection(id: number, connectionId: any) {
// alert('deleteConnection: ' + id);
var params = new HttpParams();
params = params.append('authorization', 'passing');
params = params.append('id', id);
params = params.append('connectionId', connectionId);

const request = this.httpService
Expand All @@ -77,7 +75,7 @@ export class DIOverviewComponent implements OnInit {

// if (response.ok) {
if (response.status == 200) {
alert('Delete ' + id + ' done!');
alert('Delete id:' + id + ' connectionID:' + connectionId + ' done!');
window.location.reload();
}
})
Expand Down

0 comments on commit 53fe4a9

Please sign in to comment.