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

Fix Lock Passwordless feature parity (events and quick auth screen) #1267

Merged
merged 2 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ export default class Base extends EventEmitter {
'hash_parsed',
'signin ready',
'signup ready',

'socialOrPhoneNumber ready',
'socialOrEmail ready',
'vcode ready',
'forgot_password ready',
'forgot_password submit',
'signin submit',
'signup submit',
'socialOrPhoneNumber submit',
'socialOrEmail submit',
'vcode submit',
'federated login'
];

Expand Down Expand Up @@ -136,6 +141,12 @@ export default class Base extends EventEmitter {
l.emitEvent(m, 'signup ready');
} else if (screen.name === 'forgotPassword') {
l.emitEvent(m, 'forgot_password ready');
} else if (screen.name === 'socialOrEmail') {
l.emitEvent(m, 'socialOrEmail ready');
} else if (screen.name === 'socialOrPhoneNumber') {
l.emitEvent(m, 'socialOrPhoneNumber ready');
} else if (screen.name === 'vcode') {
l.emitEvent(m, 'vcode ready');
}
}
this.oldScreenName = screen.name;
Expand Down
3 changes: 2 additions & 1 deletion src/engine/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ class Classic {
if (
lastUsedConnection &&
isSuccess(m, 'sso') &&
l.hasConnection(m, lastUsedConnection.get('name'))
l.hasConnection(m, lastUsedConnection.get('name')) &&
l.findConnection(m, lastUsedConnection.get('name')).get('type') !== 'passwordless'
) {
return new LastLoginScreen();
}
Expand Down
26 changes: 25 additions & 1 deletion src/engine/passwordless.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import LoadingScreen from '../core/loading_screen';
import SocialOrEmailLoginScreen from './passwordless/social_or_email_login_screen';
import SocialOrPhoneNumberLoginScreen from './passwordless/social_or_phone_number_login_screen';
import VcodeScreen from '../connection/passwordless/ask_vcode';
import LastLoginScreen from '../core/sso/last_login_screen';
import {
initPasswordless,
isEmail,
isSendLink,
passwordlessStarted
} from '../connection/passwordless/index';
import { initSocial } from '../connection/social/index';
import { isDone } from '../sync';
import { isDone, isSuccess } from '../sync';
import * as l from '../core/index';
import { hasSkippedQuickAuth } from '../quick_auth';
import * as sso from '../core/sso/index';

class Passwordless {
didInitialize(m, opts) {
Expand Down Expand Up @@ -49,6 +52,27 @@ class Passwordless {
return new LoadingScreen();
}

if (!hasSkippedQuickAuth(m)) {
if (l.ui.rememberLastLogin(m)) {
const lastUsedConnection = sso.lastUsedConnection(m);
const lastUsedUsername = sso.lastUsedUsername(m);
if (
lastUsedConnection &&
isSuccess(m, 'sso') &&
l.hasConnection(m, lastUsedConnection.get('name')) &&
['passwordless', 'social'].indexOf(
l.findConnection(m, lastUsedConnection.get('name')).get('type')
) >= 0 //if connection.type is either passwordless or social
) {
const conn = l.findConnection(m, lastUsedConnection.get('name'));
const connectionType = conn.get('type');
if (connectionType === 'passwordless' || connectionType === 'social') {
return new LastLoginScreen();
}
}
}
}

if (isEmail(m)) {
return isSendLink(m) || !passwordlessStarted(m)
? new SocialOrEmailLoginScreen()
Expand Down
6 changes: 6 additions & 0 deletions src/ui/box/chrome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class SubmitButton extends React.Component {
l.emitEvent(model, 'signin submit');
} else if (screenName === 'forgotPassword') {
l.emitEvent(model, 'forgot_password submit');
} else if (screenName === 'socialOrEmail') {
l.emitEvent(model, 'socialOrEmail submit');
} else if (screenName === 'socialOrPhoneNumber') {
l.emitEvent(model, 'socialOrPhoneNumber submit');
} else if (screenName === 'vcode') {
l.emitEvent(model, 'vcode submit');
}

if (this.props.onSubmit) {
Expand Down
6 changes: 6 additions & 0 deletions support/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,15 @@ <h1 class="navbar-brand">
'signin ready',
'signup ready',
'forgot_password ready',
'socialOrPhoneNumber ready',
'socialOrEmail ready',
'vcode ready',
'forgot_password submit',
'signin submit',
'signup submit',
'socialOrPhoneNumber submit',
'socialOrEmail submit',
'vcode submit',
'federated login'
];
validEvents.forEach(function (e) {
Expand Down