-
Notifications
You must be signed in to change notification settings - Fork 35
Change password passwordless #588
base: develop
Are you sure you want to change the base?
Conversation
let oldPasswordLabel = I18n.t('profile.oldPassword'); | ||
if (isSocialAccount) { | ||
oldPasswordLabel = I18n.t('profile.oldPasswordSocial'); | ||
} |
There was a problem hiding this comment.
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)", |
There was a problem hiding this comment.
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
There was a problem hiding this 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
assembl/graphql/user.py
Outdated
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): |
There was a problem hiding this comment.
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) :)
There was a problem hiding this comment.
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.
assembl/graphql/user.py
Outdated
@@ -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: |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const {newPassword2} = this.state
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.