Skip to content

Commit

Permalink
fixing setting users email in edit_user function (#197)
Browse files Browse the repository at this point in the history
* fixing edit password. the refactor on explicit authentication made it redundant some code and a previous fix didn't account for that

* trying to fix saas unit test
  • Loading branch information
edulix committed Apr 25, 2022
1 parent 0555401 commit 3308353
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
9 changes: 9 additions & 0 deletions authapi/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 authapi/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 authapi/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

0 comments on commit 3308353

Please sign in to comment.