Skip to content
Merged
Changes from 1 commit
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
10 changes: 8 additions & 2 deletions src/ui/box/container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CloseButton } from './button';
import * as l from '../../core/index';
import * as c from '../../field/index';
import { swap, updateEntity } from '../../store/index';
import { databaseUsernameValue } from '../../connection/database/index';

const badgeSvg = (
<svg focusable="false" width="58px" height="21px" viewBox="0 0 462 168">
Expand Down Expand Up @@ -69,15 +70,20 @@ export default class Container extends React.Component {
this.state = { isOpen: false };
}
checkConnectionResolver(done) {
const { contentProps } = this.props;
const { contentProps, screenName } = this.props;
const lock = contentProps.model;
const connectionResolver = l.connectionResolver(lock);
if (!connectionResolver) {
return done();
}
const { connections, id } = lock.get('client').toJS();
const context = { connections, id };
const userInputValue = c.getFieldValue(lock, 'username') || c.getFieldValue(lock, 'email');

// On signUp screen, use emailFirst option to prioritize email over username
// On login screen, use default behavior (username first)
const isSignUpScreen = screenName && screenName.includes('signUp');
const userInputValue = databaseUsernameValue(lock, isSignUpScreen ? { emailFirst: true } : {});

connectionResolver(userInputValue, context, resolvedConnection => {
swap(updateEntity, 'lock', l.id(lock), m => l.setResolvedConnection(m, resolvedConnection));
done();
Expand Down