Fixed a graphing calculator "permissions" bug caused by PR #1426 (#1471)

## Fixes a bug caused by https://github.com/microsoft/calculator/pull/1426#.


### Description of the changes:
- The PR #1426 can cause a crash when no users are returned via `User::FindAllAsync(UserType::LocalUser)` when subsequently trying to access the first user. The existing code also does not guarantee that the returned user is the currently active user.
- This fix retrieves the user that opened the app and passes this user into a function to check if this user has the proper permissions to access the graphing mode. This makes sense since the active user is indistinguishable (at least from the app's perspective) to the user who opened the app. This user's permissions are then propagated downwards to properly set up the navigation menu of the app.
- Implementation detail worth pointing out: `s_categoryManifest` is what is used to populate the navigation menu of the app, but this variable is static by design, so a separate function was written to override the appropriate `isEnabled` value in `s_categoryManifest`. This function is called by `onLaunched`.

### How changes were validated:
- Manual testing
This commit is contained in:
Wei (Waley) Zhang
2021-02-02 08:31:44 -08:00
committed by GitHub
parent d4be50490f
commit fd2367d483
3 changed files with 33 additions and 10 deletions

View File

@@ -198,12 +198,12 @@ void App::OnLaunched(LaunchActivatedEventArgs ^ args)
// If the app got pre-launch activated, then save that state in a flag
m_preLaunched = true;
}
NavCategory::InitializeCategoryManifest(args->User);
OnAppLaunch(args, args->Arguments);
}
void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument)
{
// Uncomment the following lines to display frame-rate and per-frame CPU usage info.
//#if _DEBUG
// if (IsDebuggerPresent())