public async override void OnNavigatedTo(HBNavigationEventArgs e) { base.OnNavigatedTo(e); LogoutCommand.RaiseCanExecuteChanged(); if (e.NavigationMode == NavigationMode.New) { CacheSize = GetFormatSize(await StorageHelper.GetCacheFolderSize()); } }
private void ApplicationStateService_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (ExtractMemberName(() => ApplicationStateService.CurrentUser) == e.PropertyName) { OnPropertyChanged(() => CurrentUsername); OnPropertyChanged(() => CanLogin); OnPropertyChanged(() => CanLogout); LoginCommand.RaiseCanExecuteChanged(); LogoutCommand.RaiseCanExecuteChanged(); UploadCommand.RaiseCanExecuteChanged(); } }
void NotifyProperty() { NotifyPropertyChanged(Resources.NotifyPropertyChanged_Authenticated); NotifyPropertyChanged(Resources.NotifyPropertyChanged_IsAuthenticated); NotifyPropertyChanged(Resources.NotifyPropertyChanged_IsNotAuthenticated); NotifyPropertyChanged(Resources.NotifyPropertyChanged_Status); LoginCommand.RaiseCanExecuteChanged(); LogoutCommand.RaiseCanExecuteChanged(); this.Credential.Username = string.Empty; this.Credential.Password = string.Empty; this.Credential.Status = string.Empty; Credential = Credential.CreateNewCredential(); }
private void Logout(object parameter) { CustomPrincipal customPrincipal = Thread.CurrentPrincipal as CustomPrincipal; if (customPrincipal != null) { customPrincipal.Identity = new AnonymousIdentity(); NotifyPropertyChanged("AuthenticatedUser"); NotifyPropertyChanged("IsAuthenticated"); LoginCommand.RaiseCanExecuteChanged(); LogoutCommand.RaiseCanExecuteChanged(); Status = string.Empty; } }
public void Handle(AttemptLoginResponse message) { if (message.Result.WasSuccessful) { IsConnected = true; _messageBus.Send(new LoggedInMessage()); _messageBus.LogMessage("Logged in successfully!", LogLevel.Info); } else { IsConnected = false; _messageBus.Send(new LoggedOutMessage()); _messageBus.LogMessage("Failed to log in! Reason: " + message.Result.ErrorMessage, LogLevel.Warning); } _isBusy = false; LogoutCommand.RaiseCanExecuteChanged(); LoginCommand.RaiseCanExecuteChanged(); }
private void Login(object parameter) { PasswordBox passwordBox = parameter as PasswordBox; string clearTextPassword = passwordBox.Password; try { //Validate credentials through the authentication service User user = _authenticationService.AuthenticateUser(Username, clearTextPassword); //Get the current principal object CustomPrincipal customPrincipal = Thread.CurrentPrincipal as CustomPrincipal; if (customPrincipal == null) { throw new ArgumentException("The application's default thread principal must be set to a CustomPrincipal object on startup."); } //Authenticate the user customPrincipal.Identity = new CustomIdentity(user.Username, user.Email, user.Roles); //Update UI NotifyPropertyChanged("AuthenticatedUser"); NotifyPropertyChanged("IsAuthenticated"); LoginCommand.RaiseCanExecuteChanged(); LogoutCommand.RaiseCanExecuteChanged(); Username = string.Empty; //reset passwordBox.Password = string.Empty; //reset Status = string.Empty; } catch (UnauthorizedAccessException ue) { //Status = "Login failed! Please provide some valid credentials."; Status = ue.Message; } catch (Exception ex) { Status = string.Format("ERROR: {0}", ex.Message); } }
public void RaiseCanExecuteChanged() { LoginCommand.RaiseCanExecuteChanged(); LogoutCommand.RaiseCanExecuteChanged(); OpenRegisterCommand.RaiseCanExecuteChanged(); }
private void SetIsBusy(bool isBusy) { _isBusy = isBusy; LogoutCommand.RaiseCanExecuteChanged(); LoginCommand.RaiseCanExecuteChanged(); }