public async Task HandleAsync(TCommand command, CancellationToken cancellationToken = default) { if (command is null) { throw new ArgumentNullException(nameof(command)); } var user = _securityUserProvider.GetUser(); command.SetUser(user); await _decoratee.HandleAsync(command, cancellationToken).ConfigureAwait(false); }
public async Task <TResult> HandleAsync(TQuery query, CancellationToken cancellationToken = default) { if (query is null) { throw new ArgumentNullException(nameof(query)); } var user = _securutyUserProvider.GetUser(); query.SetUser(user); return(await _decoratee.HandleAsync(query, cancellationToken).ConfigureAwait(false)); }
public void CookieAuthenticate(string visitorAddress) { HttpCookie cookie = persistenceProvider.GetAuthCookie(); if (cookie != null) { string userName; string userData = persistenceProvider.GetAuthCookieValue(out userName); string[] cookieData = userData.Split('|'); // extract data from cookie bool isValid = cookieData.Length == CookieParameterCount && !string.IsNullOrEmpty(cookieData[0]) && cookieData[0] == userName && IsAuthorizedVisitor(cookieData[1], cookieData[0], visitorAddress); if (isValid) { string customer = cookieData[1]; string[] roles = cookieData[2].Split(','); T user = userProvider.GetUser(customer, userName); CurrentPrincipal = new CodeworksPrincipal <T>(userName, roles, user); } } }