Пример #1
0
        public IActionResult ChangeRole(Passcode passcode)
        {
            try
            {
                WriteLog(LogsDef.StartLogMsg);

                var passcodeDt = passcodeRepository.ReadByIdAndCode(passcode);

                if (passcodeDt != null)
                {
                    var token = AuthenticationConfig.GenerateJSONWebToken(passcodeDt);

                    var useState = new UseState();
                    useState.Date   = DateTime.UtcNow;
                    useState.IdRole = passcodeDt.IdRole;
                    useState.Token  = token;
                    useStateRepository.Add(useState);

                    HttpContext.Session.SetObjectAsJson(SessionDef.SESSION_USESTATE, useState);
                    HttpContext.Session.SetObjectAsJson(SessionDef.SESSION_USERLOGIN, passcodeDt);
                    return(Json(true));
                }

                return(Json(false));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (Result.Length != 0)
            {
                hash ^= Result.GetHashCode();
            }
            if (Passcode.Length != 0)
            {
                hash ^= Passcode.GetHashCode();
            }
            if (CountryCode.Length != 0)
            {
                hash ^= CountryCode.GetHashCode();
            }
            if (LanguageCode.Length != 0)
            {
                hash ^= LanguageCode.GetHashCode();
            }
            if (BundleVersion.Length != 0)
            {
                hash ^= BundleVersion.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <returns> </returns>
 public Passcode ReadByIdAndCode(Passcode passcode)
 {
     return(this.context.Passcode.AsNoTracking()
            .Where(p => p.IdRole.Equals(passcode.IdRole) && p.Code.Equals(passcode.Code))
            .OrderBy(p => p.IdRole).ThenBy(a => a.Code)
            .FirstOrDefault());
 }
        public IActionResult Index()
        {
            Random rand       = new Random();
            string holdString = "";
            string chars      = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

            //step 3 repeat step 1 until 14 characters exist in holdString var
            for (int i = 1; i <= 14; i++)
            {
                //I need to randomly select 14 characters from the string of char and insert each random character into holdString var
                //step 1 randomly land on an nth element in string of char.
                int index = rand.Next(chars.Length);

                string character = chars[index].ToString();


                //step 2 insert nth element into holdString var
                holdString += character;
            }
            const string clickCountSessionKey = "clickscounted";
            {
                var model = new Passcode()
                {
                    ClickCount = 0
                };
                var previousClickCount = Session[clickCountSessionKey];
                if (previousClickCount != null)
                {
                    model.ClickCount = (int)previousClickCount;
                }
                return(View(Passcode));
            }
        }
    void Start()
    {
        base.Start();

        // initialise and set default vaiables
        _waitToReset        = new WaitForSeconds(1.0f);
        _passcode           = new Passcode();
        _worldCodeText.text = string.Format("{0}\t{1}\t{2}\t{3}", _passcode.code[0], _passcode.code[1], _passcode.code[2], _passcode.code[3]);

        // update the on screen text
        UpdateText();
        Canvas_Manager.Keypad.UpdateStatusNodes(State.Idle);
    }
Пример #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Passcode.Length != 0)
            {
                hash ^= Passcode.GetHashCode();
            }
            if (AcquiredItemsProto.Length != 0)
            {
                hash ^= AcquiredItemsProto.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Result != 0)
            {
                hash ^= Result.GetHashCode();
            }
            if (Passcode.Length != 0)
            {
                hash ^= Passcode.GetHashCode();
            }
            if (rewards_ != null)
            {
                hash ^= Rewards.GetHashCode();
            }
            return(hash);
        }
Пример #8
0
        public IActionResult Index()
        {
            int?curr = HttpContext.Session.GetInt32("count");

            if (curr == null)
            {
                HttpContext.Session.SetInt32("count", 0);
            }
            else
            {
                int currCount = (int)curr + 1;
                HttpContext.Session.SetInt32("count", currCount);
            }
            Passcode newPass = new Passcode();

            ViewBag.Pass  = newPass.randomPasscode;
            ViewBag.Count = HttpContext.Session.GetInt32("count");
            return(View());
        }
        public IActionResult Index()
        {
            int?counter = HttpContext.Session.GetInt32("Counter");

            if (counter == null)
            {
                counter = 1;
                HttpContext.Session.SetInt32("Counter", (int)counter);
            }
            else
            {
                HttpContext.Session.SetInt32("Counter", (int)++counter);
            }
            Passcode newCode = new Passcode();

            ViewBag.Counter = counter;
            ViewBag.Code    = newCode.Code;
            return(View("index"));
        }
Пример #10
0
    void CheckPasscode()
    {
        Passcode passcode = curPasscodeInput.GetComponent <Passcode>();
        string   input    = passcode.GetInput();

        Debug.Log("Input:" + input);
        Debug.Log("a:" + actionData.passcode);

        if (input.Contains(actionData.passcode))
        {
            Debug.Log("True");
            dialogueObject.SelectDialogue(actionData.passDialogueData);
        }
        else
        {
            Debug.Log("False");
            dialogueObject.SelectDialogue(actionData.failDialogueData);
        }
    }
Пример #11
0
        private const uint keypadID = 1; // smart graphic object id


        public ControlSystem()  : base()
        {
            Thread.MaxNumberOfUserThreads = 60;

            if (this.SupportsEthernet)
            {
                tsw760 = new Tsw760(0x05, this);
                string TSW760SgdFilePath = string.Format("{0}\\Passcode.sgd", Directory.GetApplicationDirectory());

                if (File.Exists(TSW760SgdFilePath))
                {
                    tsw760.LoadSmartObjects(TSW760SgdFilePath);
                    CrestronConsole.PrintLine("[SYSTEM] TSW SGD FOUND!!!");
                    PasscodeKeypad = tsw760.SmartObjects[keypadID];
                }
                else
                {
                    CrestronConsole.PrintLine("[SYSTEM] Could not find TSW SGD file. TSW SmartObjects will not work at this time");
                }


                if (tsw760.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    CrestronConsole.PrintLine("[SYSTEM] tsw760 has been registered successfully");
                }
                else
                {
                    CrestronConsole.PrintLine("[SYSTEM] tsw760 failed registration. Cause: {0}", tsw760.RegistrationFailureReason);
                }
            }
            else
            {
                CrestronConsole.PrintLine("[SYSTEM] This processor does not support ethernet, so this program will not run");
            }


            /// set up passcode
            PIN = new Passcode();
            PIN.Init(tsw760, PasscodeKeypad, passcodeChangeButton, passcodeTextField);
            PIN.debug_enable = true;
            PIN.SetCallback(PINCodeEntered);
        }
Пример #12
0
        public IActionResult Index()
        {
            int?counter = HttpContext.Session.GetInt32("counter");

            if (counter == null)
            {
                counter = 1;
                HttpContext.Session.SetInt32("counter", (int)counter);
            }
            else
            {
                counter++;
                HttpContext.Session.SetInt32("counter", (int)counter);
            }
            string code = new Passcode().Code;
            Dictionary <string, object> info = new Dictionary <string, object>();

            info["counter"] = (int)counter;
            info["code"]    = (string)code;
            return(View(info));
        }
Пример #13
0
        public static string GenerateJSONWebToken(Passcode passcode)
        {
            var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("DCE3FDD385EAF50DDAA3287FB7B89D42DFEE3BC56519593B8A11E7621EA967C1"));
            var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);

            var claims = new[]
            {
                new Claim("IdRole", passcode.IdRole.ToString()),
                new Claim("Code", passcode.Code),
            };

            var token = new JwtSecurityToken("https://localhost:44351",
                                             "https://localhost:44351",
                                             claims,
                                             DateTime.UtcNow,
                                             expires: DateTime.Now.AddMinutes(30),
                                             signingCredentials: credentials
                                             );

            return(new JwtSecurityTokenHandler().WriteToken(token));
        }
Пример #14
0
 public bool Check()
 {
     if (Passcode.Equals(keyCode))
     {
         if (PassSound != null)
         {
             PassSound.Play();
         }
         if (door != null)
         {
             door.IsLocked = false;
         }
         return(true);
     }
     else
     {
         if (FailSound != null)
         {
             FailSound.Play();
         }
         return(false);
     }
 }
 public IActionResult ClickCounter(Passcode model)
 {
     model.ClickCount++;
     Session[clickCountSessionKey] = model.ClickCount;
     return(RedirectToAction("Index"));
 }
Пример #16
0
 void Start()
 {
     passcode = GetComponent <Passcode>();
 }
 public IActionResult ClickCounter(Passcode model)
 {
     model.ClickCount++;
     Session[clickCountSessionKey] = model.ClickCount;
 }
        public IActionResult ClickCounter(Passcode model)
        {
            model.ClickCount++;

            return(RedirectToAction("Index"));
        }
Пример #19
0
 public IActionResult ClickCounter(Passcode model)
 {
     model.ClickCount++;
 }
 public IActionResult ClickCounter(Passcode model)
 {
     model.ClickCount++;
     Session[clickCountSessionKey] = model.ClickCount;
     return(View(model));
 }
Пример #21
0
 public void FocusPasscode()
 {
     PasscodeTransform.Y = 0.0;
     OptimizeFullHD();
     if (ViewModel.Simple)
     {
         PasscodeTransform.Y             = _gotFocusTransformY;
         PinKeyboard.Visibility          = Visibility.Visible;
         Passcode.Visibility             = Visibility.Collapsed;
         PasscodeNumericPanel.Visibility = Visibility.Visible;
         //Telegram.Api.Helpers.Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.5), () => PasscodeNumeric.Focus());
     }
     else
     {
         PinKeyboard.Visibility          = Visibility.Collapsed;
         Passcode.Visibility             = Visibility.Visible;
         PasscodeNumericPanel.Visibility = Visibility.Collapsed;
         Telegram.Api.Helpers.Execute.BeginOnUIThread(TimeSpan.FromSeconds(1.0), () => Passcode.Focus());
         //Passcode.Focus();
     }
 }
Пример #22
0
        internal static string Login(string username,
                                     byte[] passwordHash,
                                     string deviceId,
                                     IUi ui,
                                     ISecureStorage storage,
                                     RestClient rest)
        {
            // Try simple password login, potentially with a stored second factor token if
            // "remember me" was used before.
            var rememberMeOptions = GetRememberMeOptions(storage);
            var response          = RequestAuthToken(username, passwordHash, deviceId, rememberMeOptions, rest);

            // Simple password login (no 2FA) succeeded
            if (response.AuthToken != null)
            {
                return(response.AuthToken);
            }

            var secondFactor = response.SecondFactor;

            if (secondFactor.Methods == null || secondFactor.Methods.Count == 0)
            {
                throw new InternalErrorException("Expected a non empty list of available 2FA methods");
            }

            // We had a "remember me" token saved, but the login failed anyway. This token is not valid anymore.
            if (rememberMeOptions != null)
            {
                EraseRememberMeToken(storage);
            }

            var      method   = ChooseSecondFactorMethod(secondFactor, ui);
            var      extra    = secondFactor.Methods[method];
            Passcode passcode = null;

            switch (method)
            {
            case Response.SecondFactorMethod.GoogleAuth:
                passcode = ui.ProvideGoogleAuthPasscode();
                break;

            case Response.SecondFactorMethod.Email:
                // When only the email 2FA present, the email is sent by the server right away.
                // Trigger only when other methods are present.
                if (secondFactor.Methods.Count != 1)
                {
                    TriggerEmailMfaPasscode(username, passwordHash, rest);
                }

                passcode = ui.ProvideEmailPasscode((string)extra["Email"] ?? "");
                break;

            case Response.SecondFactorMethod.Duo:
            case Response.SecondFactorMethod.DuoOrg:
            {
                var duo = Duo.Authenticate((string)extra["Host"] ?? "",
                                           (string)extra["Signature"] ?? "",
                                           ui,
                                           rest.Transport);

                if (duo != null)
                {
                    passcode = new Passcode(duo.Passcode, duo.RememberMe);
                }

                break;
            }

            case Response.SecondFactorMethod.YubiKey:
                passcode = ui.ProvideYubiKeyPasscode();
                break;

            case Response.SecondFactorMethod.U2f:
                passcode = AskU2fPasscode(JObject.Parse((string)extra["Challenge"]), ui);
                break;

            default:
                throw new UnsupportedFeatureException($"2FA method {method} is not supported");
            }

            // We're done interacting with the UI
            ui.Close();

            if (passcode == null)
            {
                throw MakeCancelledMfaError();
            }

            var secondFactorResponse = RequestAuthToken(username,
                                                        passwordHash,
                                                        deviceId,
                                                        new SecondFactorOptions(method,
                                                                                passcode.Code,
                                                                                passcode.RememberMe),
                                                        rest);

            // Password + 2FA is successful
            if (secondFactorResponse.AuthToken != null)
            {
                SaveRememberMeToken(secondFactorResponse, storage);
                return(secondFactorResponse.AuthToken);
            }

            throw new BadMultiFactorException("Second factor code is not correct");
        }
Пример #23
0
 public IActionResult ClickCounter(Passcode model)
 {
     model.ClickCount++;
     Session[clickCountSessionKey] = model.ClickCount;
     RedirectToAction("");
 }