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

Move LoginModal username and password into instance properties, remove refs #966

Merged
merged 1 commit into from
May 11, 2019

Conversation

MikeNicholls
Copy link
Contributor

Before submitting, please confirm you've

Please provide the following information:

Summary
Resolves an issue where username and password were not being passed for HTTP basic authentication.

Issue link
Fixes #965

Test Cases

Additional Notes

@@ -9,17 +9,16 @@ export default class LoginModal extends React.Component {
constructor(props) {
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
this.usernameRef = React.createRef();
this.passwordRef = React.createRef();
this.state = {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to store this values in the component state, they can be class properties
this.username and this.password

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I don't have any React experience, so it's much appreciated. I've replaced the state two with properties.

@@ -54,7 +53,10 @@ export default class LoginModal extends React.Component {
<FormControl
type='text'
placeholder='User Name'
ref={this.usernameRef}
value={this.state.username}
Copy link
Contributor

Choose a reason for hiding this comment

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

the FormControl does not have to be re-rendered every time there is a key stroke

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, removed

@@ -54,7 +53,10 @@ export default class LoginModal extends React.Component {
<FormControl
type='text'
placeholder='User Name'
ref={this.usernameRef}
value={this.state.username}
onChange={(e) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

lets make this a function in the class something like

setUser = (e) => { this.username = e.target.value }

then the onChange prop is onChange=this.setUser

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -70,7 +72,10 @@ export default class LoginModal extends React.Component {
<FormControl
type='password'
placeholder='Password'
ref={this.passwordRef}
value={this.state.password}
onChange={(e) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

see above comment about the function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@MikeNicholls MikeNicholls changed the title Move LoginModal username and password into component state, remove refs Move LoginModal username and password into instance properties, remove refs Apr 26, 2019
@amyblais
Copy link
Member

Not sure which dev is owning reviews on this, assigning one more reviewer.

@amyblais amyblais requested a review from wget April 29, 2019 18:46
@amyblais amyblais added the 2: Dev Review Requires review by a core committer label Apr 29, 2019
@deanwhillier deanwhillier added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Apr 30, 2019
Copy link
Collaborator

@wget wget left a comment

Choose a reason for hiding this comment

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

Working completely fine.
Tested on the master branch rebased with this PR on Windows 10 and Linux.
Tests passed on Windows 10 but are still failing on Linux: https://gist.github.com/wget/b02f11e270f25244e405bef690c975e8

@wget wget merged commit 9aca5c6 into mattermost:master May 11, 2019
@amyblais amyblais added this to the v4.3.0 milestone Sep 5, 2019
JtheBAB pushed a commit to JtheBAB/desktop that referenced this pull request Jan 17, 2020
…sic Auth

Remove use of refs for login dialog username and password, shift values into instance properties instead (mattermost#966)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP basic authentication dialog not passing username and password
5 participants