Skip to content

Commit

Permalink
feat(xx): disabled login screen in XX
Browse files Browse the repository at this point in the history
  • Loading branch information
slvnperron committed Sep 21, 2018
1 parent 460892a commit fb8ddeb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ const ensureAuthenticated = WrappedComponent => {

promptLogin = () => {
const urlToken = _.get(this.props, 'location.query.token')
const pathname = this.context.router.history.location.pathname

if (location.pathname !== '/login' && !urlToken) {
this.context.router.history.push('/login?returnTo=' + this.context.router.history.location.pathname)
if (pathname !== '/login' && !urlToken) {
this.context.router.history.push('/login?returnTo=' + pathname)
}

window.botpressWebChat && window.botpressWebChat.sendEvent({ type: 'hide' })
}

Expand Down
12 changes: 12 additions & 0 deletions packages/core/botpress/src/web/views/Login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import classnames from 'classnames'

import styles from './style.scss'
import { login } from '~/util/Auth'
import { parseBotId } from '~/util'

export default class LoginPage extends Component {
static contextTypes = {
Expand All @@ -30,6 +31,13 @@ export default class LoginPage extends Component {
componentDidMount() {
const app = document.getElementById('app')
app.className = classnames(app.className, 'bp-body-login')

if (window.BOTPRESS_XX) {
const botId = parseBotId()
const returnTo = this.props.location.query.returnTo || '/'
const finalDestination = `/studio/${botId}${returnTo}`
location.replace('/admin/login?returnTo=' + finalDestination)
}
}

handlePasswordChange = event => {
Expand Down Expand Up @@ -126,6 +134,10 @@ export default class LoginPage extends Component {
}

render() {
if (window.BOTPRESS_XX) {
return null // Authenticate using the /admin panel
}

const hasChangedPassword = !!this.props.location.query.reset
const hasAnError = !!this.state.error

Expand Down

0 comments on commit fb8ddeb

Please sign in to comment.