Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1898 from blockstack/feature/better-errors-notifi…
Browse files Browse the repository at this point in the history
…cations

Name registration errors and deny button
  • Loading branch information
hstove authored May 3, 2019
2 parents 7685e7f + 16349dc commit ad05fd2
Show file tree
Hide file tree
Showing 8 changed files with 548 additions and 348 deletions.
55 changes: 37 additions & 18 deletions app/js/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,34 @@ class AuthPage extends React.Component {
if (redirectURI) {
// Get the current localhost authentication url that the app will redirect back to,
// and remove the 'echo' param from it.
const authContinuationURI = updateQueryStringParameter(window.location.href, 'echo', '')
redirectURI = updateQueryStringParameter(redirectURI, 'echoReply', this.state.echoRequestId)
redirectURI = updateQueryStringParameter(redirectURI, 'authContinuation', encodeURIComponent(authContinuationURI))
const authContinuationURI = updateQueryStringParameter(
window.location.href,
'echo',
''
)
redirectURI = updateQueryStringParameter(
redirectURI,
'echoReply',
this.state.echoRequestId
)
redirectURI = updateQueryStringParameter(
redirectURI,
'authContinuation',
encodeURIComponent(authContinuationURI)
)
} else {
throw new Error('Invalid redirect echo reply URI')
}
this.setState({ responseSent: true })
window.location = redirectURI
}

componentWillReceiveProps(nextProps) {

componentWillReceiveProps(nextProps) {
if (!this.state.responseSent) {

if (this.state.echoRequestId) {
this.redirectUserToEchoReply()
return
}
}

const storageConnected = this.props.api.storageConnected
this.setState({
Expand Down Expand Up @@ -272,9 +282,7 @@ class AuthPage extends React.Component {

if (identity.zoneFile && identity.zoneFile.length > 0) {
const zoneFileJson = parseZoneFile(identity.zoneFile)
const profileUrlFromZonefile = getTokenFileUrlFromZoneFile(
zoneFileJson
)
const profileUrlFromZonefile = getTokenFileUrlFromZoneFile(zoneFileJson)
if (
profileUrlFromZonefile !== null &&
profileUrlFromZonefile !== undefined
Expand Down Expand Up @@ -380,10 +388,7 @@ class AuthPage extends React.Component {
}

getFreshIdentities = async () => {
await this.props.refreshIdentities(
this.props.api,
this.props.addresses
)
await this.props.refreshIdentities(this.props.api, this.props.addresses)
this.setState({ refreshingIdentities: false })
}

Expand Down Expand Up @@ -575,7 +580,11 @@ class AuthPage extends React.Component {
}

render() {
const { appManifest, appManifestLoading, appManifestLoadingError } = this.props
const {
appManifest,
appManifestLoading,
appManifestLoadingError
} = this.props

if (appManifestLoadingError) {
return (
Expand Down Expand Up @@ -630,11 +639,18 @@ class AuthPage extends React.Component {
)
},
deny: () => console.log('go back to app'),
backLabel: 'Cancel',
backView: () => {
if (document.referrer === '') {
window.close()
} else {
history.back()
}
},
accounts: this.props.localIdentities,
processing: this.state.processing,
refreshingIdentities: this.state.refreshingIdentities,
selectedIndex: this.state.currentIdentityIndex,
disableBackOnView: 0
selectedIndex: this.state.currentIdentityIndex
}
},
{
Expand Down Expand Up @@ -664,4 +680,7 @@ class AuthPage extends React.Component {
}
}

export default connect(mapStateToProps, mapDispatchToProps)(AuthPage)
export default connect(
mapStateToProps,
mapDispatchToProps
)(AuthPage)
17 changes: 7 additions & 10 deletions app/js/auth/views/initial.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ const basicInfo = 'read your basic info'
const readEmail = 'read your email address'
const publishData = 'publish data stored for this app'

const Accounts = ({ list, handleClick, processing, refreshingIdentities, selectedIndex }) => {
const Accounts = ({
list,
handleClick,
processing,
refreshingIdentities,
selectedIndex
}) => {
let loadingMessage = null
if (processing) {
loadingMessage = 'Signing in...'
Expand Down Expand Up @@ -121,15 +127,6 @@ const InitialScreen = ({
</Buttons>
</>
)
},
actions: {
items: [
{
label: 'Deny',
to: '/',
negative: true
}
]
}
}
return <ShellScreen {...rest} {...props} />
Expand Down
Loading

0 comments on commit ad05fd2

Please sign in to comment.