public UserSession(IUserSettingsService userSettingsService, IDataService dataService, IAppSettings appSettings) { _userSettingsService = userSettingsService; _loginSettings = _userSettingsService.GetSettings(); _dataService = dataService; _appSettings = appSettings; }
private void LoginUser(ILoginSettings loginSettings, Action <LoginResponse> callbackAction) { _userSettingsService.SaveSettings(loginSettings); _dataService.Initialize(loginSettings); _dataService.GetUserByUserName(loginSettings.UserName).Subscribe( user => { if (user.HasPermission(Permissions.ApplicationLoginPermission)) { CurrentUser = user; _userSettingsService.SaveSettings(_loginSettings); CustomerId = _loginSettings.CustomerId; callbackAction(new LoginResponse { Response = "Login succeedet", Success = true }); } else { _userSettingsService.DeleteSettings(); callbackAction(new LoginResponse { Response = "You do not have permission to access this application.", Success = false }); } }, (e) => callbackAction(new LoginResponse { Response = e.ToString(), Success = false })); }
public async Task <bool> ValidateUser(ILoginSettings loginSettings) { _serviceStackClient.Authorize(loginSettings); using (var client = _serviceFactory.GetAuthenticationClient(loginSettings)) { return(await client.ValidateUserAsync(loginSettings.UserName, loginSettings.Password, loginSettings.CustomerId)); } }
public static IFileDownloadService GetFileDownloadClient(ILoginSettings loginSettings) { var channel = GetFileDownloadChannel(); if (channel.Endpoint.Behaviors.Find <UserCredentialsEndpointBehavior>() == null && loginSettings != null) { var customBehavior = new UserCredentialsEndpointBehavior(loginSettings.UserName, loginSettings.Password, loginSettings.CustomerId); channel.Endpoint.Behaviors.Add(customBehavior); } return(channel.CreateChannel()); }
public void Authorize(ILoginSettings loginSettings) { _jsonServiceClient.LocalHttpWebRequestFilter = LocalHttpWebRequestFilter(loginSettings); var request = new Auth { UserName = loginSettings.UserName, Password = loginSettings.Password, RememberMe = true, //important tell client to retain permanent cookies }; _jsonServiceClient.Post(request); }
private static Action <HttpWebRequest> LocalHttpWebRequestFilter(ILoginSettings loginSettings) { return(requestH => { var hasHeaders = requestH.Headers.GetValues("CustomerId") != null; if (!hasHeaders) { requestH.Headers.Add("CustomerId", loginSettings.CustomerId); requestH.Headers.Add("ClientApplicationType", "3"); } }); }
public ILoginSettings GetLoginSettings() { ILoginSettings codeService = flyWeightPool["LoginSettings"] as ILoginSettings; if (codeService == null) { codeService = new LoginSettingsServiceImpl(); flyWeightPool.Add("LoginSettings", codeService); } return(codeService); }
public bool ResetPassword(ILoginSettings loginSettings) { var client = _serviceFactory.GetAuthenticationClient(loginSettings); try { return(client.ResetPassword(loginSettings.UserName)); } finally { client.Close(); } }
public void SaveSettings(ILoginSettings loginSettings) { using (var storageFile = IsolatedStorageFile.GetUserStoreForApplication()) { using (var storageFileStream = new IsolatedStorageFileStream(STORAGE_FILE_NAME, FileMode.Create, storageFile)) { using (var streamWriter = new StreamWriter(storageFileStream)) { streamWriter.Write(SerializationUtils.Serialize(loginSettings)); streamWriter.Close(); } } } }
public TrexPortalService.TrexSlServiceClient GetServiceClient(ILoginSettings loginSettings) { var client = new TrexPortalService.TrexSlServiceClient(); client.Endpoint.Address = new EndpointAddress(_appSettings.TrexWcfServiceEndpointUri); if (client.Endpoint.Behaviors.Find <EndpointBehavior>() == null && loginSettings != null) { var customBehavior = new EndpointBehavior(loginSettings.UserName, loginSettings.Password, loginSettings.CustomerId); client.Endpoint.Behaviors.Add(customBehavior); } return(client); }
public Task AuthorizeAsync(ILoginSettings loginSettings) { var taskCompletionSource = new TaskCompletionSource <AuthResponse>(); _jsonServiceClient.LocalHttpWebRequestFilter = LocalHttpWebRequestFilter(loginSettings); var request = new Auth { UserName = loginSettings.UserName, Password = loginSettings.Password, RememberMe = true, //important tell client to retain permanent cookies }; _jsonServiceClient.PostAsync(request, taskCompletionSource.SetResult, (authResponse, error) => taskCompletionSource.SetException(error)); return(taskCompletionSource.Task); }
public void LoginUser(string username, string password, string customerId, bool persistLogin, Action <LoginResponse> callBackAction) { _loginSettings = new LoginSettings { CreateDate = DateTime.Now, UserName = username, Password = password, CustomerId = customerId, PersistLogin = persistLogin }; var authenticationService = new AuthenticationService(_loginSettings); var result = authenticationService.AuthenticateUser(username, password, customerId); result.Subscribe(isValid => { if (isValid) { LoginUser(_loginSettings, callBackAction); } else { callBackAction(new LoginResponse { Response = "Incorrect username or password", Success = false }); } }, (e) => { if (e is FaultException <ExceptionDetail> ) { var detail = ((FaultException <ExceptionDetail>)e).Detail; //if (detail.Type.Contains("UserValidationException")) callBackAction(new LoginResponse { Response = detail.Message, Success = false }); } }); }
public static ITrexService GetServiceClient(ILoginSettings loginSettings) { var binding = new CustomBinding(); binding.Elements.Add(new BinaryMessageEncodingBindingElement()); var httpTransport = new HttpTransportBindingElement { MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue }; binding.Elements.Add(httpTransport); var channel = GetDomainChannel(); if (channel.Endpoint.Behaviors.Find <UserCredentialsEndpointBehavior>() == null && loginSettings != null) { var customBehavior = new UserCredentialsEndpointBehavior(loginSettings.UserName, loginSettings.Password, loginSettings.CustomerId); channel.Endpoint.Behaviors.Add(customBehavior); } return(channel.CreateChannel()); }
public AspNetMembershipProviderSettingsWrapper(IRegistrationSettings registration, IPasswordSettings password, ILoginSettings login) { Registration = registration; Password = password; Login = login; }
public void Initialize(ILoginSettings loginSettings) { _loginSettings = loginSettings; _service = ServiceFactory.GetServiceClient(loginSettings); _loadInvoiceComment = Observable.FromAsyncPattern <int, ObservableCollection <InvoiceComment> >(_service.BeginLoadComments, _service.EndLoadComments); _saveInvoiceComment = Observable.FromAsyncPattern <string, int, int, ServerResponse>(_service.BeginSaveComment, _service.EndSaveComment); _getDebitList = Observable.FromAsyncPattern <ObservableCollection <InvoiceListItemView> >(_service.BeginGetDebitList, _service.EndGetDebitList); _recalculateInvoice = Observable.FromAsyncPattern <int, DateTime, DateTime, int>(_service.BeginRecalculateInvoice, _service.EndRecalculateInvoice); _RecalculateexclVat = Observable.FromAsyncPattern <int, double?>(_service.BeginUpdateExclVAT, _service.EndUpdateExclVAT); _getInvoiceById = Observable.FromAsyncPattern <int, Invoice>(_service.BeginGetInvoiceById, _service.EndGetInvoiceById); _saveInvoiceChanges = Observable.FromAsyncPattern <InvoiceListItemView, ServerResponse>(_service.BeginSaveInvoiceChanges, _service.EndSaveInvoiceChanges); _generateInvoiceLines = Observable.FromAsyncPattern <int>(_service.BeginGenerateInvoiceLines, _service.EndGenerateInvoiceLines); _getInvoicebyInvoiceID = Observable.FromAsyncPattern <int, InvoiceListItemView>(_service.BeginGetInvoiceByInvoiceId, _service.EndGetInvoiceByInvoiceId); _sendInvoiceMail = Observable.FromAsyncPattern <Invoice, ServerResponse>(_service.BeginSendInvoiceEmailToCustomerInvoiceGroup, _service.EndSendInvoiceEmailToCustomerInvoiceGroup); _addNewInvoiceLine = Observable.FromAsyncPattern <int, double>(_service.BeginCreateNewInvoiceLine, _service.EndCreateNewInvoiceLine); _generateCreditnote = Observable.FromAsyncPattern <int, int, ServerResponse>(_service.BeginGenerateCreditnote, _service.EndGenerateCreditnote); _getAllInvoiceIDs = Observable.FromAsyncPattern <ObservableCollection <int?> >(_service.BeginGetAllInvoiceIds, _service.EndGetAllInvoiceIds); _getAllUsers = Observable.FromAsyncPattern <ObservableCollection <User> >(_service.BeginGetAllUsers, _service.EndGetAllUsers); _getCustomerInvoiceGroupByCustomerInvoiceGroupId = Observable.FromAsyncPattern <int, CustomerInvoiceGroup>( _service.BeginGetCustomerInvoiceGroupByCustomerInvoiceFGroupId, _service.EndGetCustomerInvoiceGroupByCustomerInvoiceFGroupId); _overWriteCig = Observable.FromAsyncPattern <CustomerInvoiceGroup, ServerResponse>(_service.BeginOverWriteCig, _service.EndOverWriteCig); _getInvoiceDataByInvoiceId = Observable.FromAsyncPattern <int, ObservableCollection <TimeEntry> >(_service.BeginGetInvoiceDataByInvoiceId, _service.EndGetInvoiceDataByInvoiceId); _getFinalizedInvoiceDataByInvoiceId = Observable.FromAsyncPattern <int, ObservableCollection <CreditNote> >( _service.BeginGetFinalizedInvoiceDataByInvoiceId, _service.EndGetFinalizedInvoiceDataByInvoiceId); _deleteInvoiceDraft = Observable.FromAsyncPattern <int>(_service.BeginDeleteInvoiceDraft, _service.EndDeleteInvoiceDraft); _getInvoiceLinesByInvoiceID = Observable.FromAsyncPattern <int, ObservableCollection <InvoiceLine> >( _service.BeginGetInvoiceLinesByInvoiceId, _service.EndGetInvoiceLinesByInvoiceId); _getCustomerInvoiceGroupByCustomerId = Observable.FromAsyncPattern <int, ObservableCollection <CustomerInvoiceGroup> >( _service.BeginGetCustomerInvoiceGroupByCustomerId, _service.EndGetCustomerInvoiceGroupByCustomerId); _insertCustomerInvoiceGroup = Observable.FromAsyncPattern <ObservableCollection <CustomerInvoiceGroup>, ServerResponse>( _service.BeginInsertCustomerInvoiceGroup, _service.EndInsertCustomerInvoiceGroup); _deleteCustomerInvoiceGroup = Observable.FromAsyncPattern <int, ServerResponse>(_service.BeginDeleteCustomerInvoiceGroup, _service.EndDeleteCustomerInvoiceGroup); _generateInvoice = Observable.FromAsyncPattern <DateTime, DateTime, int, int, float, ServerResponse>( _service.BeginGenerateInvoicesFromCustomerID, _service.EndGenerateInvoicesFromCustomerID); _deleteInvoiceLine = Observable.FromAsyncPattern <int>(_service.BeginDeleteInvoiceLine, _service.EndDeleteInvoiceLine); _getUserByUserName = Observable.FromAsyncPattern <string, User>(_service.BeginGetUserByUserName, _service.EndGetUserByUserName); _getAllCustomers = Observable.FromAsyncPattern <bool, bool, bool, bool, bool, ObservableCollection <Customer> >( _service.BeginGetAllCustomers, _service.EndGetAllCustomers); _getRoles = Observable.FromAsyncPattern <ObservableCollection <Role> >(_service.BeginGetRoles, _service.EndGetRoles); _updatePermissions = Observable.FromAsyncPattern <ObservableCollection <UserPermission>, Role, int>(_service.BeginUpdatePermissions, _service.EndUpdatePermissions); _getPermissionsForRole = Observable.FromAsyncPattern <string, int, ObservableCollection <UserPermission> >( _service.BeginGetPermissionsForSingleRole, _service.EndGetPermissionsForSingleRole); _createRole = Observable.FromAsyncPattern <string>(_service.BeginCreateRole, _service.EndCreateRole); _deleteRole = Observable.FromAsyncPattern <string>(_service.BeginDeleteRole, _service.EndDeleteRole); _createUser = Observable.FromAsyncPattern <User, bool, string, UserCreationResponse>(_service.BeginCreateUser, _service.EndCreateUser); _deactivateUser = Observable.FromAsyncPattern <User>(_service.BeginDeactivateUser, _service.EndDeactivateUser); _activateUser = Observable.FromAsyncPattern <User>(_service.BeginActivateUser, _service.EndActivateUser); _deleteUser = Observable.FromAsyncPattern <User>(_service.BeginDeleteUser, _service.EndDeleteUser); _saveCustomerInvoiceGroup = Observable.FromAsyncPattern <CustomerInvoiceGroup, ServerResponse>(_service.BeginSaveCIG, _service.EndSaveCIG); _saveInvoiceLine = Observable.FromAsyncPattern <InvoiceLine, InvoiceLine>(_service.BeginSaveInvoiceLine, _service.EndSaveInvoiceLine); _saveUser = Observable.FromAsyncPattern <User>(_service.BeginSaveUser, _service.EndSaveUser); _saveCustomer = Observable.FromAsyncPattern <Customer, Customer>(_service.BeginSaveCustomer, _service.EndSaveCustomer); _saveProject = Observable.FromAsyncPattern <Project, Project>(_service.BeginSaveProject, _service.EndSaveProject); _getGlobalTimeEntryTypes = Observable.FromAsyncPattern <ObservableCollection <TimeEntryType> >(_service.BeginGetGlobalTimeEntryTypes, _service.EndGetGlobalTimeEntryTypes); _saveTimeEntry = Observable.FromAsyncPattern <TimeEntry, TimeEntry>(_service.BeginSaveTimeEntry, _service.EndSaveTimeEntry); _excludeTimeEntry = Observable.FromAsyncPattern <TimeEntry>(_service.BeginExcludeTimeEntry, _service.EndExcludeTimeEntry); _getCustomerById = Observable.FromAsyncPattern <int, bool, bool, bool, bool, bool, Customer>(_service.BeginGetCustomerById, _service.EndGetCustomerById); _getCustomerByCriterias = Observable.FromAsyncPattern <GetCustomerByIdCriterias, Customer>(_service.BeginGetCustomerByCriteria, _service.EndGetCustomerByCriteria); _saveTask = Observable.FromAsyncPattern <Task, Task>(_service.BeginSaveTask, _service.EndSaveTask); _deleteTimeEntry = Observable.FromAsyncPattern <TimeEntry, bool>(_service.BeginDeleteTimeEntry, _service.EndDeleteTimeEntry); _deleteProject = Observable.FromAsyncPattern <Project, bool>(_service.BeginDeleteProject, _service.EndDeleteProject); _deleteTask = Observable.FromAsyncPattern <Task, bool>(_service.BeginDeleteTask, _service.EndDeleteTask); _deleteCustomer = Observable.FromAsyncPattern <Customer, bool>(_service.BeginDeleteCustomer, _service.EndDeleteCustomer); _saveTimeEntryType = Observable.FromAsyncPattern <TimeEntryType, TimeEntryType>(_service.BeginSaveTimeEntryType, _service.EndSaveTimeEntryType); _getInvoicesByCustomerId = Observable.FromAsyncPattern <ObservableCollection <int>, ObservableCollection <InvoiceListItemView> >( _service.BeginGetInvoicesByCustomerId, _service.EndGetInvoicesByCustomerId); _saveInvoice = Observable.FromAsyncPattern <Invoice, Invoice>(_service.BeginSaveInvoice, _service.EndSaveInvoice); _resetPassword = Observable.FromAsyncPattern <User, string, bool>(_service.BeginResetPassword, _service.EndResetPassword); _searchTasks = Observable.FromAsyncPattern <string, ObservableCollection <Task> >(_service.BeginSearchTasks, _service.EndSearchTasks); _searchProjects = Observable.FromAsyncPattern <string, ObservableCollection <Project> >(_service.BeginSearchProjects, _service.EndSearchProjects); _getTimeEntriesByPeriod = Observable.FromAsyncPattern <DateTime, DateTime, ObservableCollection <TimeEntryView> >( _service.BeginGetTimeEntriesByPeriod, _service.EndGetTimeEntriesByPeriod); _getCustomerInvoiceViews = Observable.FromAsyncPattern <DateTime, DateTime, ObservableCollection <CustomersInvoiceView> >( _service.BeginGetCustomerInvoiceViews, _service.EndGetCustomerInvoiceViews); _getTimeEntriesForInvoicing = Observable.FromAsyncPattern <DateTime, DateTime, int, ObservableCollection <TimeEntry> >( _service.BeginGetTimeEntriesForInvoicing, _service.EndGetTimeEntriesForInvoicing); _getAllInvoiceTemplates = Observable.FromAsyncPattern <ObservableCollection <InvoiceTemplate> >( _service.BeginGetAllInvoiceTemplates, _service.EndGetAllInvoiceTemplates); _saveInvoiceTemplate = Observable.FromAsyncPattern <InvoiceTemplate>(_service.BeginSaveInvoiceTemplate, _service.EndSaveInvoiceTemplate); _saveInvoiceTemplateFile = Observable.FromAsyncPattern <byte[], int>(_service.BeginSaveInvoiceTemplateFile, _service.EndSaveInvoiceTemplateFile); _deleteInvoiceTemplate = Observable.FromAsyncPattern <InvoiceTemplate>(_service.BeginDeleteInvoiceTemplate, _service.EndDeleteInvoiceTemplate); _getAllPermissionsByClientId = Observable.FromAsyncPattern <int, ObservableCollection <UserPermission> >( _service.BeginGetAllPermissionsByClientId, _service.EndGetAllPermissionsByClientId); _getTimeEntryByTimeEntry = Observable.FromAsyncPattern <TimeEntry, TimeEntry>(_service.BeginGetTimeEntryByTimeEntry, _service.EndGetTimeEntryByTimeEntry); _UpdateTimeEntryPrice = Observable.FromAsyncPattern <int, ServerResponse>( _service.BeginUpdateTimeEntryPrice, _service.EndUpdateTimeEntryPrice); }
public AuthenticationService(ILoginSettings loginSettings) { var service = ServiceFactory.GetServiceClient(loginSettings); _authenticateUser = Observable.FromAsyncPattern <string, string, string, bool>(service.BeginValidateUserWithCustomerId, service.EndValidateUserWithCustomerId); }
public AspNetMembershipProviderSettingsWrapper(IRegistrationSettings registration, IPasswordSettings password, ILoginSettings login) { Registration = registration; Password = password; Login = login; }
public AuthenticationService.AuthenticationServiceClient GetAuthenticationClient(ILoginSettings loginSettings) { var client = new AuthenticationService.AuthenticationServiceClient(); client.Endpoint.Address = new EndpointAddress(_appSettings.AuthenticationServiceUri); if (client.Endpoint.Behaviors.Find <EndpointBehavior>() == null && loginSettings != null) { var customBehavior = new EndpointBehavior(loginSettings.UserName, loginSettings.Password, loginSettings.CustomerId); client.Endpoint.Behaviors.Add(customBehavior); } return(client); }
public UserLoggedInEventArgs(ILoginSettings loginSettings, bool loginSucceeded) { LoginSettings = loginSettings; LoginSucceeded = loginSucceeded; }
public void SaveSettings(ILoginSettings loginSettings) { _appSettings.PersistUser(loginSettings.UserName, loginSettings.Password, loginSettings.CustomerId, loginSettings.PersistLogin, loginSettings.UserId, loginSettings.UserFullName); }