コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: Pengboi/GP_Booking
 private void ReceiveLoginMessage(StaffUser userAccount)
 {
     if (userAccount.isReceptionist())
     {
         string firstname = userAccount.getFirstname();
         ViewModelLocator.Cleanup();
         CurrentToolbarViewModel = ReceptionistToolbarVM;
         CurrentViewModel        = ReceptionistVM;
         MessengerInstance.Send <NotificationMessage>(new NotificationMessage(firstname));  // FROM: MainVM TO: ReceptionistToolbarVM ~ sends logged in users first name.
     }
     else if (userAccount.isDoctor())
     {
         UserID = StaffDBConverter.GetAccountIDByUsername(userAccount.getUsername());
         CurrentToolbarViewModel = DoctorToolbarVM;
         if (PatientDBConverter.DoctorIsInAppointment(UserID))
         {
             CurrentViewModel = DoctorAppointmentVM;
             MessengerInstance.Send <int>(UserID);
         }
         else
         {
             CurrentViewModel = DoctorVM;
             MessengerInstance.Send <int>(UserID);
         }
     }
 }
コード例 #2
0
        public void SignInValidation()
        {
            StaffUser staffUser = new StaffUser(Username, Password);

            if (staffUser.userExists())
            {
                if (staffUser.verifyPassword())
                {
                    //check if account is Doctor OR Receptionist --> Otherwise trigger alert
                    if (!(staffUser.isDoctor() || staffUser.isReceptionist()))
                    {
                        Alert("Account Not Authorised", "Your account credentials are not authorised to access" +
                              " this system.");
                        return;
                    }

                    string inputtedCode = Otp();

                    string otpToken = staffUser.getOTP();
                    var    bytes    = Base32Encoding.ToBytes(otpToken);
                    var    totp     = new Totp(bytes);
                    var    totpCode = totp.ComputeTotp();

                    if (totpCode == inputtedCode)
                    {
                        //Returns user signed in to MainViewModel
                        Messenger.Default.Send <StaffUser>(new StaffUser(staffUser.getUsername(), ""));
                    }
                    else
                    {
                        Alert("One-Time Password Incorrect", "The inputted code is incorrect. Please verify your TOTP and " +
                              "retry. If issues persist, please contact the IT administrator or speak to a member of HR.");
                    }
                }
                else
                {
                    Alert("Password Incorrect", "Incorrect password. Please try again. If issues persist, please contact" +
                          " the IT administrator or speak to a member of HR.");
                }
            }
            else
            {
                Alert("User Not Found", "The account could not be found. Please check your username & try again. If issues" +
                      " persist, please contact the IT administrator or speak to a member of HR.");
            }
        }