예제 #1
0
        public async Task _1(GetUserAction _, IDispatcher dispatcher)
        {
            var state = await _authenticationStateProvider.GetAuthenticationStateAsync();

            if (state.User.Identity.IsAuthenticated)
            {
                var userId = state.User.Claims.Single(x =>
                                                      x.Type == "sub" &&
                                                      x.OriginalIssuer == _urlProvider.IdentityProvider.TrimEnd('/') &&
                                                      x.Issuer == _urlProvider.IdentityProvider.TrimEnd('/')
                                                      ).Value.Apply(Guid.Parse);
                var user = await _kvs.GetUser(userId).ToTask();

                dispatcher.Dispatch(new GetUserOutcome()
                {
                    User = user
                });
            }
            else
            {
                dispatcher.Dispatch(new GetUserOutcome()
                {
                    User = null
                });                                                // todo make record for this
            }
        }