Skip to content
This repository has been archived by the owner on Nov 29, 2019. It is now read-only.

Change password passwordless #588

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

ayyazdaniaryan
Copy link
Contributor

This code is mostly for a client who has both SSO and non-SSO users, with multiple debates on the server. The users should be able to change their passwords (or create for first time), from the V2, even if they are SSO users (who have no previous passwords). This code could be integrated into the development flow if we agree to it.

let oldPasswordLabel = I18n.t('profile.oldPassword');
if (isSocialAccount) {
oldPasswordLabel = I18n.t('profile.oldPasswordSocial');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

const oldPasswordLabel = isSocialAccount ? I18n.t('profile.oldPasswordSocial') : I18n.t('profile.oldPassword')

@@ -481,6 +481,7 @@ const Translations = {
userName: "Nom d'utilisateur",
fullname: "Nom complet",
email: "Email",
oldPasswordSocial: "Mot de passe actuel (vide si ne pas s'inscrire sur la plateforme)",
Copy link
Contributor

Choose a reason for hiding this comment

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

vide si vous n'êtes pas inscrit sur la plateforme

Copy link
Contributor

@MilanBarande MilanBarande left a comment

Choose a reason for hiding this comment

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

Javascript LGTM :) minor changes

Copy link
Contributor

@pascalhuynh pascalhuynh left a comment

Choose a reason for hiding this comment

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

LGTM

def resolve_is_social_account(self, args, context, info):
from assembl.models.social_auth import SocialAuthAccount
for a in self.accounts:
if issubclass(a.__class__, SocialAuthAccount):
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer issubclass(type(a), SocialAuthAccount) :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, yours is better because if a is None, my way would raise an exception, yours won't. Changed.

@@ -165,8 +173,9 @@ def mutate(root, args, context, info):
new_password = args.get('new_password')
new_password2 = args.get('new_password2')
# only modify the password if it was given in parameter
if old_password is not None and new_password is not None and new_password2 is not None:
if not user.check_password(old_password):
if (old_password is not None or user.password is None) and new_password is not None and new_password2 is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

None not in (new_password, new_password2)

Copy link
Contributor

Choose a reason for hiding this comment

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

password can be an empty string here! :0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this PR is to handle the condition where user.password is None. This happens when the user registered via a SSO service.

this.setState({ oldPassword: value, disabled: disabled });
};

handleNewPasswordChange = (e: SyntheticInputEvent<HTMLInputElement>) => {
const value = e.target.value;
const disabled = isEmpty(this.state.oldPassword) || isEmpty(value) || isEmpty(this.state.newPassword2);
const disabled = isEmpty(value) || isEmpty(this.state.newPassword2);
Copy link
Contributor

Choose a reason for hiding this comment

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

const {newPassword2} = this.state

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants