public BaseController() { _sendGmail = new SendGmail(); _fileSettingsServiceService = new FileSettingsServiceService(); _appAppSettings = _fileSettingsServiceService.GetSettings(); _customerSettingsService = new CustomerSettingsService(); _headersParser = new HeadersParser(); _headers = _headersParser.ParseHeadersFromFile( System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/RequestHeaders.txt")); _restService = new RestService(new HttpClientServiceFactory()); //This is now fetched via cookies parsing //_restService.SetAuthorizationHeader("Bearer", _appAppSettings.Bearer); #region get Bearer token from Cookies var cookies = _headers.SingleOrDefault(x => x.Key.ToUpper() == "COOKIE").Value.Split(';'); var bearerAuthString = cookies.First(x => x.Contains("aveapps=")).Substring(10); _restService.SetAuthorizationHeader("Bearer", bearerAuthString); #endregion #region check for expired authorization var getUser = _restService.Get <User>("https://api.waveapps.com/user/"); if (!getUser.IsSuccessStatusCode) { throw new InvalidCredentialException(); } #endregion }
public DelegationsApiController(IAuthorizationService authorizationService, IDelegationService delegationService, IRoleService roleService, IAdminUserRoleService adminUserRoleService, IGroupService groupService, ICustomerSettingsService customerSettingsService, IConnectionInfo connectionInfo, IAuditService auditService, IUserService userService) { _authorizationService = authorizationService; _delegationService = delegationService; _roleService = roleService; _adminUserRoleService = adminUserRoleService; _groupService = groupService; _connectionInfo = connectionInfo; _customerSettingsService = customerSettingsService; _auditService = auditService; _auditHelper = new AuditHelper(); _userService = userService; }