コード例 #1
0
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            Button clickBtn = (Button)sender;

            if (clickBtn.Content.ToString() == "Sign Up!")
            {
                SignUp signUpWindow = new SignUp();
                App.Current.MainWindow = signUpWindow;
                this.Close();
                signUpWindow.Show();
            }
            else if (clickBtn.Content.ToString() == "Login") // Need to add extra parameters for adding the correct user information
            {
                LoginMethods loginMethods = new LoginMethods();
                userID = loginMethods.emailCheck(emailText.Text, passwordTxt.Password);
                if (userID > 0)
                {
                    Library libraryWindow = new Library();
                    App.Current.MainWindow = libraryWindow;
                    this.Close();
                    libraryWindow.Show();
                }
                else
                {
                    invalidLoginTxt.Text = "Login Failed - Invalid Username or Password";
                }
            }
            else if (clickBtn.Content.ToString() == "Admin") // Need to add extra parameters for adding the correct user information
            {
                Admin AdminWindow = new Admin();
                App.Current.MainWindow = AdminWindow;
                this.Close();
                AdminWindow.Show();
            }
        }
コード例 #2
0
        public void WhenAuthing_LoginMethodValidatorIsChecked(LoginMethods i_method)
        {
            MockPreferredLogin.LoginMethod.Returns(i_method);

            systemUnderTest.Authenticate();

            MockLoginMethodValidator.Received().IsValid(i_method);
        }
コード例 #3
0
 public void AttemptToLink(LoginMethods i_linkType, Callback <AccountLinkResultTypes> i_callback)
 {
     switch (i_linkType)
     {
     case LoginMethods.Google:
         GoogleLinker.AttemptLink(i_callback);
         break;
     }
 }
コード例 #4
0
        public void WhenAuthing_IfMethodIsNotValid_MethodIsDefaultedToDeviceId(LoginMethods i_method)
        {
            MockPreferredLogin.LoginMethod.Returns(i_method);
            MockLoginMethodValidator.IsValid(i_method).Returns(false);

            systemUnderTest.Authenticate();

            Assert.AreEqual(LoginMethods.DeviceId, MockPreferredLogin.LoginMethod);
        }
コード例 #5
0
 public bool IsValid(LoginMethods i_method)
 {
     if (i_method == LoginMethods.DeviceId)
     {
         return(true);
     }
     else
     {
         UnityEngine.Debug.LogError("Checking is authed: " + Social.localUser.authenticated);
         return(Social.localUser.authenticated);
     }
 }
コード例 #6
0
        public void AttemptForceLink(LoginMethods i_linkType, Callback <bool> i_callback)
        {
            bool forceLink = true;

            switch (i_linkType)
            {
            case LoginMethods.Google:
                GoogleLinker.AttemptLink((result) => {
                    bool success = result == AccountLinkResultTypes.SuccessfulLink;
                    i_callback(success);
                }, forceLink);
                break;
            }
        }
コード例 #7
0
        public void LoginUserTest(ISignedUser externalValidUsers)
        {
            //Arrange
            LoginMethods login           = new LoginMethods();
            string       expectedResult  = "ALREADY REGISTERED?";
            string       expectedResult2 = "MY ACCOUNT";
            //Step 1
            string actualResult = login.GoToAuthentication().GetTextLogoAlreadyRegistered();

            Assert.AreEqual(expectedResult, actualResult, "Step1: Go to Authentication page ");
            //Step 2
            string actualResult2 = login.InputEmailPasswordForLogin(externalValidUsers).GetTextTitleMyAccount();

            Assert.AreEqual(expectedResult2, actualResult2, "Step 2: User on MyAccount page");
        }
コード例 #8
0
        //[Test, TestCaseSource("ValidUsers")]
        public void MultipleLoginUserTest(IApplicationSource applicationSource, ISignedUser validUsers)
        {
            //Arrange
            Application.GetMultipleBrowser(applicationSource).BaseUrlAction();
            LoginMethods login           = new LoginMethods();
            string       expectedResult  = "ALREADY REGISTERED?";
            string       expectedResult2 = "MY ACCOUNT";
            //Step 1
            string actualResult = login.GoToAuthentication().GetTextLogoAlreadyRegistered();

            Assert.AreEqual(expectedResult, actualResult, "Step1: Go to Authentication page ");
            //Step 2
            string actualResult2 = login.InputEmailPasswordForLogin(validUsers).GetTextTitleMyAccount();

            Assert.AreEqual(expectedResult2, actualResult2, "Step 2: User on MyAccount page");
        }
コード例 #9
0
        public void AfterLogin_IfNotUsingDeviceId_LinkDeviceToAccount(LoginMethods i_method)
        {
            MockPreferredLogin.LoginMethod.Returns(i_method);
            MockLoginMethodValidator.IsValid(i_method).Returns(true);

            IBasicBackend mockBackend = Substitute.For <IBasicBackend>();

            MockBackendManager.GetBackend <IBasicBackend>().Returns(mockBackend);

            systemUnderTest.OnLogin();

            if (i_method != LoginMethods.DeviceId)
            {
                mockBackend.Received().LinkDeviceToAccount(Arg.Any <Callback <bool> >());
            }
        }
コード例 #10
0
        public ActionResult Login(string UserName, string Password)
        {
            //var pasassas = EncryptDecrypt.Encrypt("PA$$W0RD");
            bool   flag   = false;
            string action = string.Empty;

            if (new UserDataAccess().GetUserByUserID(UserName) != null /*LoginMethods.ValidateLogin(UserName)*/)
            {
                flag = LoginMethods.Login(UserName, Password); //DB login

                //flag = Auth(UserName, Password); //AD login
                var userId = LoginMethods.IsUserExists(UserName);

                if (flag)
                {
                    bool IsDBExist = LoginMethods.Login2(UserName);//AD login
                    if (IsDBExist == false)
                    {
                        return(Json(new { IsSuccess = flag, ErrorMessage = (flag == true) ? string.Empty : "User Not Exist in System", Response = (flag == true) ? action : null }, JsonRequestBehavior.AllowGet));
                    }

                    bool expiry = LoginMethods.CheckExpiry(UserName);
                    if (expiry == false)
                    {
                        return(Json(new { IsSuccess = false, ErrorMessage = "User Access Expired", Response = "" }, JsonRequestBehavior.AllowGet));
                    }
                    LoginMethods.AddUserLog(userId.GetValueOrDefault(), userId.GetValueOrDefault());
                }

                else
                {
                    if (userId > 0)
                    {
                        LoginMethods.AddUserLog(userId.GetValueOrDefault());
                    }
                }

                action = Url.Action("DashboardView", "Base");


                return(Json(new { IsSuccess = flag, ErrorMessage = (flag == true) ? string.Empty : CustomMessages.InvalidUsernameOrPassword, Response = (flag == true) ? action : null }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { IsSuccess = flag, ErrorMessage = (flag == true) ? string.Empty : CustomMessages.UserNotExists, Response = (flag == true) ? action : null }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #11
0
        public IHttpActionResult Authenticate(LoginRequest login)
        {
            if (login == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            //TODO: Validate credentials correctly, this code is only for demo!!
            bool isCredentialValid = (login.Password == LoginMethods.GetUserPassword(login.Username));

            if (isCredentialValid)
            {
                var token = TokenGenerator.GenerateTokenJwt(login.Username);
                return(Ok(token));
            }
            else
            {
                return(Unauthorized());
            }
        }
コード例 #12
0
 public void OnClick(LoginMethods i_loginMethod)
 {
     mMethod = i_loginMethod;
     AccountLinker.AttemptToLink(i_loginMethod, OnLinkResult);
 }