Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,37 @@ function applyQueryOverridesToDeclaration(
}
}

// Login
if (query.get('login') !== 'no') {
const shouldSetLoginToTrue = () => {
/**
* Allow the Query API to explicitly set login
* if the login query param is provided.
*/
if (query.get('login') === 'no') {
return false;
}
if (query.get('login') === 'yes') {
return true;
}

/**
* Set login to true by default in the Blueprint
* only if it doesn't already contain a login step or shorthand.
* Otherwise, the login provided by the blueprint would be overridden.
*/
if (
blueprint.steps?.some(
(step) =>
step && typeof step === 'object' && step?.step === 'login'
)
) {
return false;
}
if (blueprint.login !== undefined) {
return false;
}
return true;
};
if (shouldSetLoginToTrue()) {
blueprint.login = true;
}
Comment on lines +218 to 250
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about this?

Suggested change
const shouldSetLoginToTrue = () => {
/**
* Allow the Query API to explicitly set login
* if the login query param is provided.
*/
if (query.get('login') === 'no') {
return false;
}
if (query.get('login') === 'yes') {
return true;
}
/**
* Set login to true by default in the Blueprint
* only if it doesn't already contain a login step or shorthand.
* Otherwise, the login provided by the blueprint would be overridden.
*/
if (
blueprint.steps?.some(
(step) =>
step && typeof step === 'object' && step?.step === 'login'
)
) {
return false;
}
if (blueprint.login !== undefined) {
return false;
}
return true;
};
if (shouldSetLoginToTrue()) {
blueprint.login = true;
}
// Override the `login` property if explicitly requested:
if (query.get('login') === 'yes') {
blueprint.login = true;
} else if(query.get('login') === 'no') {
blueprint.login = false;
}


Expand Down