Skip to content

Commit

Permalink
clean up into helper function and rename
Browse files Browse the repository at this point in the history
  • Loading branch information
outofambit committed May 4, 2020
1 parent 51c8a77 commit 2fbab9b
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions app/src/ui/lib/authentication-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class AuthenticationForm extends React.Component<

public render() {
const content = this.props.supportsBasicAuth ? (
this.renderEndpointRequiresWebFlowContent()
this.renderEndpointRequiresWebFlow()
) : this.props.endpoint === getDotComAPIEndpoint() ? (
this.renderUsernamePassword()
) : (
Expand Down Expand Up @@ -154,41 +154,16 @@ export class AuthenticationForm extends React.Component<
)
}

private renderEndpointRequiresWebFlowContent() {
private renderEndpointRequiresWebFlow() {
return (
<>
{this.props.supportsBasicAuth && this.renderEndpointRequiresWebFlow()}
{getWebSignInRequiredMessage(this.props.endpoint)}

{this.renderSignInWithBrowserButton()}
</>
)
}

private renderEndpointRequiresWebFlow() {
if (this.props.endpoint === getDotComAPIEndpoint()) {
return (
<>
<p>
To improve the security of your account, GitHub now requires you to
sign in through your browser.
</p>
<p>
Your browser will redirect you back to GitHub Desktop once you've
signed in. If your browser asks for your permission to launch GitHub
Desktop please allow it to.
</p>
</>
)
} else {
return (
<p>
Your GitHub Enterprise Server instance requires you to sign in with
your browser.
</p>
)
}
}

private renderSignInWithBrowserButton() {
return (
<Button
Expand Down Expand Up @@ -230,3 +205,28 @@ export class AuthenticationForm extends React.Component<
this.props.onSubmit(this.state.username, this.state.password)
}
}

function getWebSignInRequiredMessage(endpoint: string): JSX.Element {
if (endpoint === getDotComAPIEndpoint()) {
return (
<>
<p>
To improve the security of your account, GitHub now requires you to
sign in through your browser.
</p>
<p>
Your browser will redirect you back to GitHub Desktop once you've
signed in. If your browser asks for your permission to launch GitHub
Desktop please allow it to.
</p>
</>
)
} else {
return (
<p>
Your GitHub Enterprise Server instance requires you to sign in with your
browser.
</p>
)
}
}

0 comments on commit 2fbab9b

Please sign in to comment.