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

fixing setting users email in edit_user function #197

Merged
merged 2 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions iam/api/fixtures/saas.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
"fields": {
"census": "open",
"extra_fields": [
{
"name":"tlf",
"min":2,
"unique":true,
"max":200,
"type":"tlf",
"required":true,
"required_on_authentication":true
},
{
"name":"Email",
"min":2,
Expand Down
1 change: 0 additions & 1 deletion iam/authmethods/m_emailpwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def authenticate_error(self, error, req, ae):
def authenticate(self, auth_event, request, mode='authenticate'):
d = {'status': 'ok'}
req = json.loads(request.body.decode('utf-8'))
password = req.get('password', '')

msg = ""
msg += check_fields_in_request(req, auth_event, 'authenticate')
Expand Down
16 changes: 1 addition & 15 deletions iam/authmethods/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,20 +771,6 @@ def get_cannonical_tlf(tlf):


def edit_user(user, req, auth_event):
if auth_event.auth_method == 'user-and-password':
req.pop('username')
req.pop('password')
elif auth_event.auth_method == 'email-and-password':
req.pop('email')
req.pop('password')

if req.get('email'):
user.email = req.get('email')
req.pop('email')
if req.get('tlf'):
user.userdata.tlf = get_cannonical_tlf(req['tlf'])
req.pop('tlf')

if auth_event.extra_fields:
for extra in auth_event.extra_fields:
if extra.get('type') not in req:
Expand Down Expand Up @@ -975,7 +961,7 @@ def post_verify_fields_on_auth(user, req, auth_event):
for field in auth_event.extra_fields:
if not field.get('required_on_authentication'):
continue

# Raise exception if a required field is not provided.
# It will be catched by parent as an error.
if field.get('name') not in req:
Expand Down