Closed waldekmastykarz closed 8 months ago
Hello waldekmastykarz, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback š
Happy to help with fixing the issue. Shall we update the code or the docs?
@waldekmastykarz we're actually planning to deprecate all of these events with the next version of the login component (https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/main/specs/mgt-login.md). The same events are available on the auth providers so are redundant.
Do you see the same issue when using these events from a provider?
Understood. If I followed the code correctly, it seems like events in providers use a custom implementation for dispatching events, which doesn't support bubbling or cancelling at all and is just calling all registered handlers passing the event object:
I think in the context of Provider, cancelling or bubbling doesn't make sense because events communicate state change that's already done and can't be cancelled. But I do wonder if we removed events from the Login component, how would you cancel login just based on the Provider events?
@waldekmastykarz can you provide some use cases/scenarios for when you would want to cancel login from the provider?
User selected the wrong account and wants to cancel the process would be one scenario I can think of. Another could be that the login process is stuck and I want to restart it.
At the moment, this is not something we're likely to prioritize. That being said, the Graph Toolkit is an open source project and we'll be happy to support and review if you want to contribute to its codebase! In the meantime, we will be closing this issue. Thanks!
According to our docs, the
loginInitiated
event in the login component is cancelable: https://docs.microsoft.com/en-us/graph/toolkit/components/login?context=graph%2Fapi%2F1.0&view=graph-rest-1.0#eventsHowever, looking at our code, it seems like the
cancelable
property is not set and defaults tofalse
.https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/66a5bbb6591e6260e95dbc00c0d06bcbe8dcef38/packages/mgt-components/src/components/mgt-login/mgt-login.ts#L128
I noticed that we're checking the return value of the
dispatchEvent
function called internally, but according to MDN:So if I understand this correctly, unless the event object we pass into the
dispatchEvent
function has thecancelable
property set totrue
,dispatchEvent
would always returntrue
.Should we update our docs to align with the code or shall we update the code to match the docs?
The same applies by the way to the
logoutInitiated
event.