Пример #1
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.");
            }
        }