private User AddUserDetailsToContext(HttpContextAccessor httpContextAccessor) { var adminUser = _applicationService.GetUsers(null, null, null, "EmailAddress", "ASC", "Authorised", "Admin", null, null).FirstOrDefault(); var logOnUser = new DTO.Request.Application.User { OrganisationId = adminUser.OrganisationId, DisplayName = adminUser.DisplayName, EmailAddress = adminUser.EmailAddress }; var loggedOnAdminUser = _applicationService.LogonUser(logOnUser); IList <Claim> claimCollection = new List <Claim> { new Claim("UserId", loggedOnAdminUser.UserId.ToString()), new Claim("UserSessionId", loggedOnAdminUser.UserSessionId.ToString()) }; var identity = new GenericIdentity(loggedOnAdminUser.DisplayName, "TestAdminUser"); identity.AddClaims(claimCollection); var contextUser = new ClaimsPrincipal(identity); var httpContext = new DefaultHttpContext() { User = contextUser, }; httpContextAccessor.HttpContext = httpContext; return(loggedOnAdminUser); }
public void SetUserAuthorised(DTO.Request.Application.User user) { var functionName = "application.set_user_isauthorised"; var parameters = new DynamicParameters(); parameters.Add("_email_address", user.EmailAddress); parameters.Add("_is_authorised", user.IsAuthorised); _dataService.ExecuteFunction(functionName, parameters); }
public User LogoffUser(DTO.Request.Application.User user) { var functionName = "application.logoff_user"; var parameters = new DynamicParameters(); parameters.Add("_email_address", user.EmailAddress); parameters.Add("_user_session_id", user.UserSessionId); var result = _dataService.ExecuteFunction <User>(functionName, parameters); return(result.FirstOrDefault()); }
public User LogonUser(DTO.Request.Application.User user) { var functionName = "application.logon_user"; var parameters = new DynamicParameters(); parameters.Add("_email_address", user.EmailAddress); parameters.Add("_display_name", user.DisplayName); parameters.Add("_organisation_id", user.OrganisationId); var result = _dataService.ExecuteFunction <User>(functionName, parameters); return(result.FirstOrDefault()); }