Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Commit 2d88aa7

Browse files
authored
Fix Lock Passwordless feature parity (events and quick auth screen) (auth0#1267)
* Add "Last time you logged in with" screen to pwdless * Emmit missing events for Passwordless
1 parent 16e6c04 commit 2d88aa7

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed

src/core.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ export default class Base extends EventEmitter {
4343
'hash_parsed',
4444
'signin ready',
4545
'signup ready',
46-
46+
'socialOrPhoneNumber ready',
47+
'socialOrEmail ready',
48+
'vcode ready',
4749
'forgot_password ready',
4850
'forgot_password submit',
4951
'signin submit',
5052
'signup submit',
53+
'socialOrPhoneNumber submit',
54+
'socialOrEmail submit',
55+
'vcode submit',
5156
'federated login'
5257
];
5358

@@ -136,6 +141,12 @@ export default class Base extends EventEmitter {
136141
l.emitEvent(m, 'signup ready');
137142
} else if (screen.name === 'forgotPassword') {
138143
l.emitEvent(m, 'forgot_password ready');
144+
} else if (screen.name === 'socialOrEmail') {
145+
l.emitEvent(m, 'socialOrEmail ready');
146+
} else if (screen.name === 'socialOrPhoneNumber') {
147+
l.emitEvent(m, 'socialOrPhoneNumber ready');
148+
} else if (screen.name === 'vcode') {
149+
l.emitEvent(m, 'vcode ready');
139150
}
140151
}
141152
this.oldScreenName = screen.name;

src/engine/classic.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ class Classic {
181181
if (
182182
lastUsedConnection &&
183183
isSuccess(m, 'sso') &&
184-
l.hasConnection(m, lastUsedConnection.get('name'))
184+
l.hasConnection(m, lastUsedConnection.get('name')) &&
185+
l.findConnection(m, lastUsedConnection.get('name')).get('type') !== 'passwordless'
185186
) {
186187
return new LastLoginScreen();
187188
}

src/engine/passwordless.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ import LoadingScreen from '../core/loading_screen';
44
import SocialOrEmailLoginScreen from './passwordless/social_or_email_login_screen';
55
import SocialOrPhoneNumberLoginScreen from './passwordless/social_or_phone_number_login_screen';
66
import VcodeScreen from '../connection/passwordless/ask_vcode';
7+
import LastLoginScreen from '../core/sso/last_login_screen';
78
import {
89
initPasswordless,
910
isEmail,
1011
isSendLink,
1112
passwordlessStarted
1213
} from '../connection/passwordless/index';
1314
import { initSocial } from '../connection/social/index';
14-
import { isDone } from '../sync';
15+
import { isDone, isSuccess } from '../sync';
1516
import * as l from '../core/index';
17+
import { hasSkippedQuickAuth } from '../quick_auth';
18+
import * as sso from '../core/sso/index';
1619

1720
class Passwordless {
1821
didInitialize(m, opts) {
@@ -49,6 +52,27 @@ class Passwordless {
4952
return new LoadingScreen();
5053
}
5154

55+
if (!hasSkippedQuickAuth(m)) {
56+
if (l.ui.rememberLastLogin(m)) {
57+
const lastUsedConnection = sso.lastUsedConnection(m);
58+
const lastUsedUsername = sso.lastUsedUsername(m);
59+
if (
60+
lastUsedConnection &&
61+
isSuccess(m, 'sso') &&
62+
l.hasConnection(m, lastUsedConnection.get('name')) &&
63+
['passwordless', 'social'].indexOf(
64+
l.findConnection(m, lastUsedConnection.get('name')).get('type')
65+
) >= 0 //if connection.type is either passwordless or social
66+
) {
67+
const conn = l.findConnection(m, lastUsedConnection.get('name'));
68+
const connectionType = conn.get('type');
69+
if (connectionType === 'passwordless' || connectionType === 'social') {
70+
return new LastLoginScreen();
71+
}
72+
}
73+
}
74+
}
75+
5276
if (isEmail(m)) {
5377
return isSendLink(m) || !passwordlessStarted(m)
5478
? new SocialOrEmailLoginScreen()

src/ui/box/chrome.jsx

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ class SubmitButton extends React.Component {
2222
l.emitEvent(model, 'signin submit');
2323
} else if (screenName === 'forgotPassword') {
2424
l.emitEvent(model, 'forgot_password submit');
25+
} else if (screenName === 'socialOrEmail') {
26+
l.emitEvent(model, 'socialOrEmail submit');
27+
} else if (screenName === 'socialOrPhoneNumber') {
28+
l.emitEvent(model, 'socialOrPhoneNumber submit');
29+
} else if (screenName === 'vcode') {
30+
l.emitEvent(model, 'vcode submit');
2531
}
2632

2733
if (this.props.onSubmit) {

support/index.html

+6
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,15 @@ <h1 class="navbar-brand">
8282
'signin ready',
8383
'signup ready',
8484
'forgot_password ready',
85+
'socialOrPhoneNumber ready',
86+
'socialOrEmail ready',
87+
'vcode ready',
8588
'forgot_password submit',
8689
'signin submit',
8790
'signup submit',
91+
'socialOrPhoneNumber submit',
92+
'socialOrEmail submit',
93+
'vcode submit',
8894
'federated login'
8995
];
9096
validEvents.forEach(function (e) {

0 commit comments

Comments
 (0)