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

Add credential to user after creation #21221

Merged
merged 1 commit into from
Jun 28, 2024
Merged
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
5 changes: 5 additions & 0 deletions src/panels/config/users/dialog-add-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ export class DialogAddUser extends LitElement {
}

user.username = this._username;
user.credentials = [
{
type: "homeassistant",
},
];
this._params!.userAddedCallback(user);
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using non-null assertion.

The non-null assertion operator is used here, which can lead to runtime errors if not handled properly. Consider using optional chaining to safely access properties.

- this._params!.userAddedCallback(user);
+ this._params?.userAddedCallback(user);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this._params!.userAddedCallback(user);
this._params?.userAddedCallback(user);
Tools
Biome

[error] 298-298: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

this._close();
}
Expand Down
Loading