Skip to content

Conversation

@taraepp
Copy link
Collaborator

@taraepp taraepp commented Nov 4, 2025

Objective

  • add more fields to DB table and FE, similar to core users
    • in addition, add versioning (like core users)
  • every single user in prod has "username_or_email" ending in "@bceid", so migrated data accordingly (renamed the column to bceid_username)
  • made some FE & BE updates to reflect that this was no longer a field that may contain an email address

MDS-6691

Why are you making this change? Provide a short explanation and/or screenshots
The User Access table (same on Core):
image

Admin page on Core (got bonus columns and quick TS update):
image

…e data. Add more fields to MS user table, update model. Add versioning, fix issues with circular dependencies so it works. Update a field name. TS-ify the user list page
if not bceid_username:
raise AssertionError('Identifier is not provided.')
return email_or_username
if not bceid_username.endswith('@bceid'):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added a BE error when there's a bad BCeID passed in from the FE. I didn't add validation on the FE, figuring that the form will be revamped.



class User(SoftDeleteMixin, AuditMixin, Base):
class User(HistoryMixin, SoftDeleteMixin, AuditMixin, Base):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

was mostly experimenting when I was trying to figure out why versioning wasn't working! Anyway, this adds a history attribute that'll have nicely parsed data, so I left it in.


user = User.create_or_update_user(**user_data)
if is_minespace_user():
# bceid given/family name may be combined
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

my particular token data has the following:
given_name: "Tara Epp"
display_name: "Tara Epp"
family_name: ""

It's a pretty small sample size, but prod data can be checked later on to see how the parsing is going and possibly modify it from there. The display_name is what's used by the FE.



def get_mine_access():
from .api.users.minespace.models.minespace_user import MinespaceUser
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the imports from MinespaceUser before the app is initialized is what caused versioning to not work, so now they're loaded in the functions. There is a BE test added to catch the versioning breaking again.

if given_name == display_name and family_name == "":
name = display_name.split()
given_name = name[0] if len(name) > 0 else ""
family_name = name[1] if len(name) > 1 else ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm thinking we might just want to accept empty family name if not provided in the bceid mapping, as in some cases this wouldn't be correct (e.g. in my case!)

Given Name: Simen Fivelstad
Family Name: Smaaberg

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm yeah. Yours would parse as given (the if would be false) but we may as well see how weird the data is before trying to clean it. Using display_name on the FE prevents the weirdness from showing up anywhere visible to any users.

}

user = MinespaceUser.update_from_token_data(**user_data)
print(user)
Copy link
Collaborator

Choose a reason for hiding this comment

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

print

if request.args.get('email_or_username'):
ms_users = [MinespaceUser.find_by_email(request.args.get('email_or_username'))]
if request.args.get('bceid_username'):
ms_users = [MinespaceUser.find_by_username(request.args.get('bceid_username'))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm something feels a bit odd with this logic here reading this whole function. I think we should probably also filter this by the mine_guid you pass in if you're a minespace proponent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is some 5 year old code, which, based on the FE code, I think is actually just dead. There's no calls to the API matching this resource where we do a GET with anything other than mine_guid. I'll take it out.

asinn134
asinn134 previously approved these changes Nov 4, 2025
Copy link
Collaborator

@matbusby-fw matbusby-fw left a comment

Choose a reason for hiding this comment

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

Looks great. Just one small change request on a function name for consistency.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 5, 2025

Quality Gate Passed Quality Gate passed for 'bcgov-sonarcloud_mds_minespace-web'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 5, 2025

Quality Gate Failed Quality Gate failed for 'bcgov-sonarcloud_mds_common'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 5, 2025

Quality Gate Failed Quality Gate failed for 'bcgov-sonarcloud_mds_core-web'

Failed conditions
69.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 5, 2025

@taraepp taraepp requested a review from matbusby-fw November 5, 2025 21:27
@taraepp taraepp merged commit 290465d into develop Nov 6, 2025
18 of 20 checks passed
@taraepp taraepp deleted the mds-6691-ms-user-info branch November 6, 2025 18:49
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.

5 participants