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

249/user cannot change email #6439

Merged
merged 13 commits into from
Oct 6, 2021
Merged

249/user cannot change email #6439

merged 13 commits into from
Oct 6, 2021

Conversation

isalikov
Copy link
Contributor

@isalikov isalikov commented Sep 24, 2021

What

  • Users can change email
    image

@isalikov isalikov temporarily deployed to more-secrets September 24, 2021 14:12 Inactive
@isalikov isalikov temporarily deployed to more-secrets September 24, 2021 14:29 Inactive
Copy link
Contributor

@jamakase jamakase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Few comments about the implementation + I suppose only 1 thing is missed - I do not see error handling. What if reauthenticateWithCredential fails? Or password will be too weak? Firebase doc includes list of possible errors

async changePassword(passwd: string, newPassword: string): Promise<void> {
const user = await this.getCurrentUser()!;

const credential = EmailAuthProvider.credential(user.email!, passwd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to avoid ! even though we have it in some places.

Is it possible for this email to be empty? if yes - lets check it for null and through error otherwise. Credential should always be a email, right?

{ currentPassword: string; password: string }
>(
async ({ password, currentPassword }) => {
return authService.changePassword(currentPassword, password);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should call services/auth service. We do not want this logic to spread everywhere. I suppose you need to add proxy to this method in AuthContext


import {
Content,
SettingsCard,
} from "pages/SettingsPage/pages/SettingsComponents";
import { FieldItem } from "packages/cloud/views/auth/components/FormComponents";
import { LabeledInput } from "components/LabeledInput";
import { Button } from "../../../../../../components/base/Button";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small style comment: let's order lib import ( react-query ) above our imports. And get rig of ../../../

await userService.changeEmail(email);
},
{
onSuccess: () => window.location.reload(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to reload page?

});
>(
async ({ email, passwd }) => {
await authService.changeEmail(email, passwd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic leak here. Let's place it into AuthService just how all other auth services handle it. It already has access to authService and userService, so you won't need to do any initial initialization

@CLAassistant
Copy link

CLAassistant commented Sep 27, 2021

CLA assistant check
All committers have signed the CLA.

@isalikov isalikov temporarily deployed to more-secrets September 29, 2021 08:15 Inactive
@isalikov isalikov temporarily deployed to more-secrets October 1, 2021 17:27 Inactive
@isalikov isalikov linked an issue Oct 1, 2021 that may be closed by this pull request
@isalikov isalikov temporarily deployed to more-secrets October 3, 2021 11:20 Inactive
@isalikov isalikov temporarily deployed to more-secrets October 4, 2021 11:43 Inactive
if (user) {
await this.reauthenticate(email, password);

return updateEmail(user, email);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, I think you could just use await updateEmail here

return updateEmail(user, email);
}

return Promise.resolve();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need of this promise.resolve as void is returned, so you can just return; or do nothing.

const cloudWorkspace = await this.fetch<CloudWorkspace>(`${this.url}/get`, {
public async get(workspaceId?: string | null): Promise<CloudWorkspace> {
if (!workspaceId) {
return Promise.resolve({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could just return object. No need to return Promise. ts will interfere types correctly as method is async

@@ -0,0 +1,5 @@
export type FormValues = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use d.ts extensions here as .d.ts is bridge between ts and js. We use just simple ts.

disabled={!dirty}
onClick={() => resetForm()}
>
cancel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, looks like we forgot to add it into locale. Let's add it.

@isalikov isalikov temporarily deployed to more-secrets October 5, 2021 15:33 Inactive
@isalikov isalikov temporarily deployed to more-secrets October 6, 2021 08:58 Inactive
@jamakase jamakase merged commit 370805e into master Oct 6, 2021
@jamakase jamakase deleted the 249/User-cannot-change-email branch October 6, 2021 10:58
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
* feat: change user email

* feat: added password submit for change email

* feat: password change section

* feat: rename workspace

* fix: workspace names

* fix: auth refactoring

* fix: change password onSuccess

* fix: change workspaces name

* fix: change user email hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cloud password reset not working
3 participants