-
Notifications
You must be signed in to change notification settings - Fork 37
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
Use token roles in controllers #1211
Conversation
🔔 Changes in database folder detected 🔔 |
fb90f1f
to
f1eeb1f
Compare
f591391
to
8e791f0
Compare
4947cbe
to
a24c520
Compare
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'd say we take this in now, and test it a bit afterwards to verify desired behaviour :)
🔔 Migrations changes detected 🔔 |
a9ba9e7
to
bfab212
Compare
@@ -169,7 +169,7 @@ private IQueryable<MissionRun> GetMissionRunsWithSubModels() | |||
.ThenInclude(robot => robot.Model) | |||
.Include(missionRun => missionRun.Tasks) | |||
.ThenInclude(task => task.Inspections) | |||
.Where((m) => accessibleInstallationCodes.Result.Contains(m.Area.Installation.InstallationCode)); ; | |||
.Where((m) => m.Area == null || accessibleInstallationCodes.Result.Contains(m.Area.Installation.InstallationCode.ToUpper())); ; |
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.
Will installation1 users get all missions from installation2 without an area? (Applies for the change in MissionDefinitionService.cs as well)
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.
If a missionRun does not have an area it also does not have an installation. We can enforce the use of Area in missionRun maybe but I think this will require some refactoring for the localisation code
@@ -133,8 +133,8 @@ public async Task<MissionRun> Update(MissionRun missionRun) | |||
if (missionRun.Area is not null) { context.Entry(missionRun.Area).State = EntityState.Unchanged; } | |||
|
|||
var entry = context.Update(missionRun); | |||
await context.SaveChangesAsync(); | |||
_ = signalRService.SendMessageAsync("Mission run updated", new MissionRunResponse(missionRun)); | |||
await ApplyDatabaseUpdate(missionRun.Area?.Installation); |
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.
Is this not updated from the mqtt? Do we need to check this?
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 think it is good to collect all the updates to one function so that it is easier to debug and protect in the future. It can get messy otherwise. The function should be able to handle not being called from a HTTP request
d238431
to
b4d91ff
Compare
I think it is ready to merge, but I'll wait to add new missions to huldra in echo before merging it |
b6cc9d2
to
ad56069
Compare
/UpdateDatabase |
👀 Running migration command... 👀 |
❌ Migration failed, please see action log below for details ❌ |
/UpdateDatabase |
👀 Running migration command... 👀 |
❌ Migration failed, please see action log below for details ❌ |
Also add access roles as migrations
Also add mocked tokens to make tests pass Also made Installation an object ref in Robot
/UpdateDatabase |
👀 Running migration command... 👀 |
✨ Successfully ran migration command! ✨ |
Makes it so that data models that have an associated installation are only returned or able to be set in requests when the user has the associated role in their bearer token. If the user has a generic role, such as Role.User or Role.Admin, then all data models are available.
Things that are currently missing which need to be added before merging: