Skip to content

Commit d4d9c25

Browse files
Merge branch 'hot_fix_sign_in_via_login_and_password'
2 parents 401f4de + d018ecd commit d4d9c25

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

client/src/app/styles/_buttons.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
height: four-by(6);
7474
margin-right: four-by(3);
7575
}
76+
77+
&:disabled {
78+
background-color: $bg-color;
79+
opacity: 0.4;
80+
}
7681
}
7782

7883
.link-button {

client/src/modules/user/AuthBox/components/SignInForm.jsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class SignInForm extends PureComponent {
3333
noAccount: false,
3434
password: '',
3535
pending: false,
36+
pendingForGoogle: false,
3637
signInErrorId: ''
3738
};
3839

@@ -117,7 +118,7 @@ class SignInForm extends PureComponent {
117118
url = `/auth/google/sign-up/${JSON.stringify(data)}`;
118119
}
119120

120-
this.setState({ pending: true });
121+
this.setState({ pendingForGoogle: true });
121122

122123
window.location = url;
123124
};
@@ -130,21 +131,19 @@ class SignInForm extends PureComponent {
130131
this.setState({ pending: true });
131132
this.pendingPromise = makeAbortablePromise(signIn(email, password));
132133

133-
return this.pendingPromise.promise
134-
.then(() => this.setState({ pending: false }))
135-
.catch(err => {
136-
if (!(err instanceof AbortPromiseException)) {
137-
const newState = { pending: false };
138-
139-
if (err instanceof UnauthorizedException) {
140-
newState.signInErrorId = 'user.actions.sign-in.invalid-credentials';
141-
} else {
142-
newState.signInErrorId = 'common.something-went-wrong';
143-
}
134+
return this.pendingPromise.promise.catch(err => {
135+
if (!(err instanceof AbortPromiseException)) {
136+
const newState = { pending: false };
144137

145-
this.setState(newState);
138+
if (err instanceof UnauthorizedException) {
139+
newState.signInErrorId = 'user.actions.sign-in.invalid-credentials';
140+
} else {
141+
newState.signInErrorId = 'common.something-went-wrong';
146142
}
147-
});
143+
144+
this.setState(newState);
145+
}
146+
});
148147
};
149148

150149
renderSignInError = () => {
@@ -180,11 +179,13 @@ class SignInForm extends PureComponent {
180179
isPolicyAccepted,
181180
noAccount,
182181
pending,
182+
pendingForGoogle,
183183
signInErrorId
184184
} = this.state;
185185
const { isCookieSet } = this.props;
186186
const hasSignUpFailed = signInErrorId.length > 0;
187-
const isDisabled = !isCookieSet || pending;
187+
const isGoogleSignInDisabled = !isCookieSet || pending || pendingForGoogle;
188+
const isSignInDisabled = isGoogleSignInDisabled || !isFormValid;
188189
const cookieLink = (
189190
<Link className="sign-up-form__link" to="/cookie-policy">
190191
<FormattedMessage id="app.footer.cookie-policy" />
@@ -232,7 +233,7 @@ class SignInForm extends PureComponent {
232233
<form
233234
className="sign-in__form"
234235
noValidate
235-
onSubmit={isFormValid && !pending ? this.handleSignIn : null}
236+
onSubmit={isSignInDisabled ? null : this.handleSignIn}
236237
>
237238
<AuthInput
238239
disabled={pending}
@@ -259,7 +260,7 @@ class SignInForm extends PureComponent {
259260
</Link>
260261
<PendingButton
261262
className="primary-button sign-in__confirm"
262-
disabled={!isFormValid}
263+
disabled={isSignInDisabled}
263264
onClick={this.handleSignIn}
264265
type="submit"
265266
>
@@ -285,8 +286,9 @@ class SignInForm extends PureComponent {
285286
<div className="sign-in__buttons">
286287
<button
287288
className={classNames('primary-button google-button', {
288-
'disabled-google-button': isDisabled
289+
'disabled-google-button': isGoogleSignInDisabled
289290
})}
291+
disabled={isGoogleSignInDisabled}
290292
onClick={this.handleSignInWithGoogle}
291293
type="submit"
292294
>
@@ -296,7 +298,7 @@ class SignInForm extends PureComponent {
296298
) : (
297299
<FormattedMessage id="user.auth.sign-in-with-google" />
298300
)}
299-
{pending && <Preloader size={PreloaderSize.SMALL} />}
301+
{pendingForGoogle && <Preloader size={PreloaderSize.SMALL} />}
300302
</button>
301303
</div>
302304
</form>

client/src/modules/user/AuthBox/components/SignUpForm.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class SignUpForm extends PureComponent {
5050
name: '',
5151
password: '',
5252
pending: false,
53+
pendingForGoogle: false,
5354
signUpErrorId: ''
5455
};
5556
}
@@ -322,8 +323,11 @@ class SignUpForm extends PureComponent {
322323
isFormValid,
323324
isPolicyAccepted,
324325
pending,
326+
pendingForGoogle,
325327
signUpErrorId
326328
} = this.state;
329+
const isGoogleSignUpDisabled = pending || pendingForGoogle;
330+
const isSignUpDisabled = isGoogleSignUpDisabled || !isFormValid;
327331
const cookieLink = (
328332
<Link className="sign-up-form__link" to="/cookie-policy">
329333
<FormattedMessage id="app.footer.cookie-policy" />
@@ -369,7 +373,7 @@ class SignUpForm extends PureComponent {
369373
<form
370374
className="sign-up-form__form"
371375
noValidate
372-
onSubmit={isFormValid && !pending ? this.handleSignUp : null}
376+
onSubmit={isSignUpDisabled ? null : this.handleSignUp}
373377
>
374378
<AuthInput
375379
disabled={pending}
@@ -422,7 +426,7 @@ class SignUpForm extends PureComponent {
422426
</Link>
423427
<PendingButton
424428
className="primary-button sign-up-form__confirm"
425-
disabled={!isFormValid}
429+
disabled={isSignUpDisabled}
426430
onClick={this.handleSignUp}
427431
type="submit"
428432
>
@@ -435,12 +439,13 @@ class SignUpForm extends PureComponent {
435439
<div className="sign-up-form__google">
436440
<button
437441
className="primary-button sign-up-form__confirm google-button"
442+
disabled={isGoogleSignUpDisabled}
438443
onClick={this.signUpWithGoogle}
439444
type="submit"
440445
>
441446
<GoogleIcon />
442447
<FormattedMessage id="user.auth.sign-up-with-google" />
443-
{pending && <Preloader size={PreloaderSize.SMALL} />}
448+
{pendingForGoogle && <Preloader size={PreloaderSize.SMALL} />}
444449
</button>
445450
</div>
446451
</form>
@@ -465,7 +470,7 @@ class SignUpForm extends PureComponent {
465470
const data = {};
466471
data.policyAcceptedAt = isPolicyAccepted ? Date.now() : null;
467472

468-
this.setState({ pending: true });
473+
this.setState({ pendingForGoogle: true });
469474

470475
window.location = `/auth/google/sign-up/${JSON.stringify(data)}`;
471476
};

client/src/modules/user/model/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const signIn = (email, password) => dispatch =>
100100
.then(response => response.json())
101101
.then(json => {
102102
dispatch(loginSuccess(json));
103+
history.push('/');
103104
createNotificationWithTimeout(dispatch, NotificationType.SUCCESS, {
104105
notificationId: 'user.actions.login'
105106
});

0 commit comments

Comments
 (0)