Skip to content

Commit

Permalink
Merge pull request #1534 from famedly/nico/simplify-sorting
Browse files Browse the repository at this point in the history
refactor: simplify UIA stage selection logic
  • Loading branch information
nico-famedly authored Aug 1, 2023
2 parents b27fd45 + 59693b7 commit 4addccd
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/src/utils/uia_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,11 @@ class UiaRequest<T> {
List<AuthenticationFlow> flows, List<String> completed) {
final nextStages = <String>{};
for (final flow in flows) {
final stages = flow.stages;
final nextStage = stages[completed.length];
var stagesValid = true;
for (var i = 0; i < completed.length; i++) {
if (stages[i] != completed[i]) {
stagesValid = false;
break;
}
}
if (stagesValid) {
nextStages.add(nextStage);
// check the flow starts with the completed stages
if (flow.stages.length >= completed.length &&
flow.stages.take(completed.length).toSet().containsAll(completed)) {
final stages = flow.stages.skip(completed.length);
if (stages.isNotEmpty) nextStages.add(stages.first);
}
}
return nextStages;
Expand Down

0 comments on commit 4addccd

Please sign in to comment.