refactor: simplify UIA stage selection logic
(Also prevents a potential out of bounds exception)
This commit is contained in:
parent
334c9e3b78
commit
59693b7375
|
|
@ -102,17 +102,11 @@ class UiaRequest<T> {
|
||||||
List<AuthenticationFlow> flows, List<String> completed) {
|
List<AuthenticationFlow> flows, List<String> completed) {
|
||||||
final nextStages = <String>{};
|
final nextStages = <String>{};
|
||||||
for (final flow in flows) {
|
for (final flow in flows) {
|
||||||
final stages = flow.stages;
|
// check the flow starts with the completed stages
|
||||||
final nextStage = stages[completed.length];
|
if (flow.stages.length >= completed.length &&
|
||||||
var stagesValid = true;
|
flow.stages.take(completed.length).toSet().containsAll(completed)) {
|
||||||
for (var i = 0; i < completed.length; i++) {
|
final stages = flow.stages.skip(completed.length);
|
||||||
if (stages[i] != completed[i]) {
|
if (stages.isNotEmpty) nextStages.add(stages.first);
|
||||||
stagesValid = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (stagesValid) {
|
|
||||||
nextStages.add(nextStage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nextStages;
|
return nextStages;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue