private void sessionDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { SignInData data = (SignInData)senderGrid.CurrentRow.DataBoundItem; DataGridViewCellCollection cells = senderGrid.CurrentRow.Cells; NameValueCollection session = CreateSession(data, cells); this.dataWriter.Command = new LogSessionCommand(this.database, session); try { int rowsInserted = this.dataWriter.ExecuteCommand(); if (rowsInserted == 0) { this.messageHandler.ShowDialog("Logging Error", "Failed to log session. Please try again.", MessageBoxIcon.Error); } else { this.loggedSessionCache.Add(data); senderGrid.Rows.Remove(senderGrid.CurrentRow); } } catch (SQLiteException ex) { this.messageHandler.ShowDialog("Database Error", ex.Message, MessageBoxIcon.Error); } } }
public async Task Login_Successful_ReturnsLoginData() { var loginDto = new LoginDto() { Username = "******", Password = "******" }; var signInResponse = MySignInResult.Success; var signInData = new SignInData { Token = new TokenModel("Bearer", "veryFancyToken", DateTime.Now.AddDays(5)) }; _mockUserService.Setup(x => x.SignIn(loginDto.Username, loginDto.Password)) .ReturnsAsync((signInResponse, signInData)); var result = await _sut.Login(loginDto); var resultAlt = await _sut.LoginForm(loginDto); result.Should().BeEquivalentTo(resultAlt); result.Result.Should().BeAssignableTo(typeof(OkObjectResult)); var tokenResult = (LoginResponseDto)((OkObjectResult)result.Result).Value; tokenResult.TokenType.Should().Be(signInData.Token.TokenType); tokenResult.AccessToken.Should().Be(signInData.Token.AccessToken); tokenResult.Username.Should().Be(signInData.Username); tokenResult.ExpiresIn.Should().BePositive(); }
public async Task <IActionResult> SignIn(SignInData model) { Before(); if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(model.Nickname, model.Password, true, false); if (result.Succeeded) { // проверяем, принадлежит ли URL приложению if (!string.IsNullOrEmpty(model.ReturnUrl) && Url.IsLocalUrl(model.ReturnUrl)) { return(Redirect(model.ReturnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", "Неправильный логин и (или) пароль"); } } return(View(model)); }
public override JsonOperationResponseBase OnOperation(Arguments arguments, Authentication authentication) { ContentType = "text/plain"; SignInData request = new SignInData() { password = arguments["password"], username = arguments["username"] }; if (!request.IsValidRequest()) { return(new SignInResponse() { Error = "All fields were not filled out" }); } Session session = UserManager.Instance.SignInAsUser(request.username, request.password); if (session == null) { return(new SignInResponse() { Error = "Either the specified username or the password was wrong" }); } OutputConsole.WriteLine(request.username + " signed in"); return(new SignInResponse() { sessionID = session.Key }); }
//////////////////////////////////////////////////////////////////// // Helper test function to perform common SignIn routine private SignInPage PerformSignIn(SignInData p_SignInData) { // Verify driver is initialized Assert.IsNotNull(driver, "Driver initialization FAILED"); // Verify input SignInData Assert.IsNotNull(p_SignInData, "TestData load FAILED"); // Verify Home page is loaded HomePage homePage = new HomePage(driver); Assert.IsTrue(homePage.VerifyPage(), "HomePage VerifyPage() FAILED"); // Verify SignIn page is loaded SignInPage signInPage = homePage.ClickSignUp(); Assert.IsNotNull(signInPage, "ClickSignUp() FAILED"); Assert.IsTrue(signInPage.VerifyPage(), "SignInPage VerifyPage() FAILED"); // Verify test data are set Assert.IsTrue(signInPage.SetUserName(p_SignInData.userName), "SetUserName() FAILED"); Assert.IsTrue(signInPage.SetPassword(p_SignInData.password), "SetPassword() FAILED"); // Verify SigIn button is clicked Assert.IsTrue(signInPage.ClickSignIn(), "ClickSignIn() FAILED"); return(signInPage); }
public void SignIn(string username, string password) { SignInData signInData = new SignInData(username, password); var postData = JsonUtility.ToJson(signInData); StartCoroutine(SendPostRequest(postData, HTTPNetworkConstant.signInRequestURL)); }
private void OnSignInSuccessfully(SignInData obj) { signInStatus = new SignInStatusEvent { status = obj.Status, Msg = obj.Message }; sendSignInStatus = true; Debug.Log("Signin Successfull........"); }
public static User ToUser(this SignInData data) { User result = new() { Email = data.Email, Password = data.Password }; return(result); } }
public async Task <TokenResult> GetToken(string subject) { logger.Info("Getting user token"); var requestData = new SignInData { CompanyId = options.CompanyId, SharedSecret = options.SharedSecret, UserId = subject }; return(await httpClientService.PostDeserializedAsync <SignInData, TokenResult>(new Uri(options.CreateTokenUrl), requestData)); }
public IActionResult SignIn(SignInData model) { var tempUsers = new[] { "[email protected]", "[email protected]", "[email protected]" }; if (model.Email == "admin" && model.Password == "admin") { return(Ok(true)); } if (tempUsers.Contains(model.Email.ToLower())) { return(Ok(false)); } return(Unauthorized()); }
public void TestSignIn() { // Verify TestData is loaded Assert.IsNotNull(testData, "TestData load FAILED"); // Perform SigIn SignInData signInData = testData.GetTestData("TestSignIn"); PerformSignIn(signInData); // Verify SignInSuccessPage is loaded SignInSuccessPage signInSuccessPage = new SignInSuccessPage(driver); Assert.IsTrue(signInSuccessPage.VerifyPage(), "SignInSuccessPage VerifyPage() FAILED"); Assert.IsTrue(signInSuccessPage.VerifySignInHomePage(signInData.userName), "VerifySignInHomePage() FAILED"); }
public static void UpdateSignInCredentials(string userName, string email, Action <SignInData> successHandler, Action <string, string> exceptionHandler) { string apiStr = "verifyuser&username={0}&email={1}"; WWWForm form = new WWWForm(); NetworkRequestSignal requestSignal = new NetworkRequestSignal() { RequestType = RequestType.PostAndGet, URL = string.Format(apiStr, userName, email), OnSuccessHandler = (value) => { string tempStr = value; if (tempStr.Contains("")) { string[] fields = tempStr.Split(','); SignInData sdData = new SignInData(); for (int j = 0; j < fields.Length; j++) { string testStr2 = fields[j].Replace("\"", ""); testStr2 = testStr2.Replace("{", ""); testStr2 = testStr2.Replace("}", ""); string[] vals = testStr2.Split(':'); if (vals.Length > 1) { if (vals[0].Equals("status")) { sdData.Status = vals[1] == "true" ? true : false; } if (vals[0].Equals("message")) { sdData.Message = vals[1]; } } } successHandler?.Invoke(sdData); } else { exceptionHandler?.Invoke("Failed deserialization", ""); } }, OnExceptionHandler = exceptionHandler, Form = form }; OnRequestEvent(requestSignal); }
public async Task <IActionResult> Login(SignInData data, string returnUrl = null) { ViewData["returnUrl"] = returnUrl; if (!ModelState.IsValid) { return(View(data)); } User corr = await UserManager.FindByEmailAsync(data.Email); if (corr?.Password == data?.Password) { await SignInManager.SignInAsync(corr, false); return(Redirect(returnUrl ?? "/")); } return(View(data)); }
public void TestSignIn() { //Verify input SignInData Assert.IsNotNull(testData, "TestData Load Failed"); SignInData signInData = testData.GetTestData("TestSignIn"); // Perform Sign In PerformSignIn(signInData); //Verify SignInSuccessPage is loaded SignInSuccessPage signInSuccessPage = new SignInSuccessPage(driver); Assert.IsTrue(signInSuccessPage.VerifyPage(), "SignInSuccessPage VerifyPage() FAILED"); Assert.IsTrue(signInSuccessPage.ClickMyAccount(), "SignInSuccessPage ClickMyAccount() FAILED"); // Verify profile email MyProfilePage myProfilePage = new MyProfilePage(driver); Assert.IsTrue(myProfilePage.VerifyPage(), "MyProfilePage VerifyPage() FAILED"); Assert.IsTrue(myProfilePage.VerifyMyProfileEmail(signInData.userName), "MyProfliPage VerifyProfilePage() FAILED"); }
public void TestForgotPassswordWithInvalidEmailId() { // Verify TestData is loaded Assert.IsTrue(testData.isLoaded, "TestData load FAILED"); // Verify test data SignInData signInData = testData.GetTestData("TestForgotPassswordWithInvalidEmailId"); Assert.IsNotNull(testData, "TestData load FAILED"); HomePage homePage = new HomePage(driver); bool isPageVerified = homePage.VerifyPage(); Assert.IsTrue(isPageVerified, "VerifyPage() FAILED"); SignInPage signInPage = homePage.GoToSignInPage(); Assert.IsNotNull(signInPage, "GoToSignInPage() FAILED"); isPageVerified = signInPage.VerifyPage(); Assert.IsTrue(isPageVerified, "VerifyPage() FAILED"); ForgotPasswordPage forgotPasswordPage = signInPage.GoToForgotPasswordPage(); Assert.IsNotNull(forgotPasswordPage, "GoToForgotPasswordPage() FAILED"); isPageVerified = forgotPasswordPage.VerifyPage(); Assert.IsTrue(isPageVerified, "VerifyPage() FAILED"); Assert.IsTrue(forgotPasswordPage.SetEmailaddress(signInData.userName), "SetEmailaddress() FAILED"); signInPage = forgotPasswordPage.ClickResetPasswordButton(); Assert.IsNotNull(signInPage, "ClickResetPasswordButton() FAILED"); isPageVerified = forgotPasswordPage.VerifyPage(); Assert.IsTrue(isPageVerified, "VerifyPage() FAILED"); isPageVerified = forgotPasswordPage.VerifyForgotPasswordErrorMessage(); Assert.IsTrue(isPageVerified, "VerifyForgotPasswordErrorMessage() FAILED"); }
private NameValueCollection CreateSession(SignInData data, DataGridViewCellCollection cells) { this.dataReader.Command = new GetLastInsertedRowIDCommand(this.database, "Session"); NameValueCollection sessionData = new NameValueCollection(); var id = this.dataReader.ExecuteCommand().FirstOrDefault(); string sessionID = id == null ? "0" : (Convert.ToInt32(id[0]) + 1).ToString(); sessionData.Add("ID", sessionID); sessionData.Add("StudentID", data.StudentID); sessionData.Add("Timestamp", data.Timestamp.ToString()); sessionData.Add("FName", data.FName); sessionData.Add("LName", data.LName); sessionData.Add("Notes", cells["Notes"].Value.ToString()); sessionData.Add("IsWorkshop", Convert.ToBoolean(cells["IsWorkshop"].Value).ToString()); this.dataReader.Command = new GetReferenceIDCommand(this.database, "Campus", "Name", cells["Campus"].Value.ToString()); string campusID = this.dataReader.ExecuteCommand().First()[0]; sessionData.Add("CampusID", campusID); this.dataReader.Command = new GetReferenceIDCommand(this.database, "Course", "Name", cells["Course"].Value.ToString()); string courseID = this.dataReader.ExecuteCommand().First()[0]; sessionData.Add("CourseID", courseID); this.dataReader.Command = new GetReferenceIDCommand(this.database, "Center", "Name", cells["Center"].Value.ToString()); string centerID = this.dataReader.ExecuteCommand().First()[0]; sessionData.Add("CenterID", centerID); sessionData.Add("TutorID", cells["Tutor"].Value.ToString()); sessionData.Add("Topics", cells["Topics"].Value.ToString()); return(sessionData); }
//public void SigninWithCredential() //{ // Debug.Log(String.Format("Attempting to sign in as {0}...", email)); // DisableUI(); // Firebase.Auth.Credential credential = Firebase.Auth.EmailAuthProvider.GetCredential(email, password); // auth.SignInWithCredentialAsync(credential).ContinueWith(HandleSignIn); //} private SignInData HandleSignIn(Task <Firebase.Auth.FirebaseUser> task) { password = ""; Debug.Log("Handling"); SignInData data = new SignInData(); EnableUI(); // some call backs when sign in is complete try { data.Message = task.Result.DisplayName == "" ? task.Result.Email : task.Result.DisplayName; data.IsSuccessful = true; } catch (System.AggregateException e) { data.IsSuccessful = false; foreach (var exception in e.Flatten().InnerExceptions) { if (exception is Firebase.FirebaseException) { Debug.LogWarning("Firebase: " + exception.Message); data.Message = exception.Message; } else { Debug.LogError(exception.Message); } } } LogTaskCompletion(task, "Sign-in"); return(data); }
public async Task ExternalLogin_Successful_ReturnsLoginData() { var loginDto = new ExternalLoginDto() { Provider = ExternalAuthenticationProvider.Google, IdToken = "idToken" }; var signInResponse = MySignInResult.Success; var signInData = new SignInData { Token = new TokenModel("Bearer", "veryFancyToken", DateTime.Now.AddDays(5)) }; _mockExternalSignInService.Setup(x => x.SignInExternal(loginDto.Provider, loginDto.IdToken)) .ReturnsAsync((signInResponse, signInData)); var result = await _sut.ExternalLogin(loginDto); result.Result.Should().BeAssignableTo(typeof(OkObjectResult)); var tokenResult = (LoginResponseDto)((OkObjectResult)result.Result).Value; tokenResult.TokenType.Should().Be(signInData.Token.TokenType); tokenResult.AccessToken.Should().Be(signInData.Token.AccessToken); tokenResult.Username.Should().Be(signInData.Username); tokenResult.ExpiresIn.Should().BePositive(); }
public Task <AuthenticationResult> PreAuthenticateAsync(SignInData signInData) { return(Task.FromResult <AuthenticationResult>(null)); }
/// <summary> /// Authentication from within our control, so we have the username and password. /// Find the user and get the claims. It doesn't seem to automatically create new users here. /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <param name="signInData"></param> /// <returns></returns> public async Task <AuthenticationResult> AuthenticateLocalAsync(string username, string password, SignInData signInData) { if (manager.SupportsUserPassword) { var user = await manager.FindByNameAsync(username); if (user != null) { if (manager.SupportsUserLockout && await manager.IsLockedOutAsync(user.Id)) { return(null); } if (await manager.CheckPasswordAsync(user, password)) { if (manager.SupportsUserLockout) { await manager.ResetAccessFailedCountAsync(user.Id); } var result = await PostAuthenticateLocalAsync(user, signInData); if (result == null) { var claims = await GetClaimsForAuthenticateResult(user); return(new AuthenticationResult(user.Id.ToString(), await GetDisplayNameForAccountAsync(user.Id), claims)); } return(result); } else if (manager.SupportsUserLockout) { await manager.AccessFailedAsync(user.Id); } } } return(null); }
/// <summary> /// External: The user has logged in on some other site /// Either we are supplied a new identity, in which case we add it to our user store /// Or we are supplied an existing identity, in which case we return the claims for this user /// </summary> /// <param name="identity"></param> /// <param name="signInData"></param> /// <returns></returns> public async Task <AuthenticationResult> AuthenticateExternalAsync(ExternalIdentity identity, SignInData signInData) { //There must be an identity for this to make sense if (identity == null) { throw new ArgumentNullException("identity"); } //The user manager tries to find a matching user var user = await manager.FindAsync(new Microsoft.AspNet.Identity.UserLoginInfo(identity.Provider, identity.ProviderId)); if (user == null) { //Create a new account return(await ProcessNewExternalAccountAsync(identity.Provider, identity.ProviderId, identity.Claims)); } else { return(await ProcessExistingExternalAccountAsync(user.Id, identity.Provider, identity.ProviderId, identity.Claims)); } }
public Task <AuthenticationResult> AuthenticateExternalAsync(ExternalIdentity identity, SignInData signInData) { throw new NotImplementedException(); }
public async Task <AuthenticationResult> AuthenticateExternalAsync(ExternalIdentity identity, SignInData signInData) { if (identity == null) { throw new ArgumentNullException("externalUser"); } try { var tenant = String.IsNullOrWhiteSpace(signInData.Tenant) ? userAccountService.Configuration.DefaultTenant : signInData.Tenant; var acct = this.userAccountService.GetByLinkedAccount(tenant, identity.Provider, identity.ProviderId); if (acct == null) { return(await ProcessNewExternalAccountAsync(tenant, identity.Provider, identity.ProviderId, identity.Claims)); } else { return(await ProcessExistingExternalAccountAsync(acct.ID, identity.Provider, identity.ProviderId, identity.Claims)); } } catch (ValidationException ex) { return(await Task.FromResult(new AuthenticationResult(ex.Message))); } }
protected Task <AuthenticationResult> PostAuthenticateLocalAsync(TAccount account, SignInData message) { return(Task.FromResult <AuthenticationResult>(null)); }
protected bool ValidateLocalCredentials(string username, string password, SignInData message, out TAccount account) { var tenant = String.IsNullOrWhiteSpace(message.Tenant) ? userAccountService.Configuration.DefaultTenant : message.Tenant; return(userAccountService.Authenticate(tenant, username, password, out account)); }
private bool IsLogged(SignInData element) { return(this.loggedSessionCache.Contains(element)); }
public Task <AuthenticationResult> PostAuthenticateAsync(SignInData signInData, AuthenticationResult authenticationResult) { return(Task.FromResult(authenticationResult)); }
public async Task <AuthenticationResult> AuthenticateLocalAsync(string username, string password, SignInData signInData) { AuthenticationResult result = null; try { TAccount account; if (ValidateLocalCredentials(username, password, signInData, out account)) { result = await PostAuthenticateLocalAsync(account, signInData); if (result == null) { var subject = GetSubjectForAccount(account); var name = GetDisplayNameForAccount(account.ID); var claims = await GetClaimsForAuthenticateResultAsync(account); result = new AuthenticationResult(subject, name, claims); } } else { if (account != null) { if (!account.IsLoginAllowed) { result = new AuthenticationResult("Account is not allowed to login"); } else if (account.IsAccountClosed) { result = new AuthenticationResult("Account is closed"); } } } } catch (ValidationException ex) { result = new AuthenticationResult(ex.Message); } return(result); }
public async Task <AuthenticationResult> AuthenticateLocalAsync(string username, string password, SignInData signInData) { try { var user = await ValidateLocalCredentials(username, password); if (user != null) { return(new AuthenticationResult(user.Id, user.UserName, Enumerable.Empty <Claim>())); } else { return(new AuthenticationResult("Account is not able to log in.")); } } catch (Exception e) { Console.WriteLine($"Exception occurred while authenticating user {username}: {e}"); throw; } }
public override JsonOperationResponseBase OnOperation(Arguments arguments, Authentication authentication) { SignInData request = new SignInData() { password = arguments["password"], playfabID = arguments["playfabID"], username = arguments["username"] }; if (!request.IsValidRequest()) { return(new SignInResponse() { Error = "All fields were not filled out" }); } Session session = UserManager.Instance.SignInAsUser(request.username, request.password); if (session == null) { return(new SignInResponse() { Error = "Either the specified username or the password was wrong" }); } User user = UserManager.Instance.GetUserFromId(session.OwnerUserID); if (!string.IsNullOrWhiteSpace(user.PlayfabID) && user.PlayfabID != request.playfabID) { return(new SignInResponse() { Error = "The provided playfabID did not match the one associated with this account" }); } else if (string.IsNullOrWhiteSpace(user.PlayfabID)) { if (UserManager.Instance.GetUserFromPlayfabID(request.playfabID) != null) { return(new SignInResponse() { Error = "The provided playfabID is already associated with an account." }); } user.PlayfabID = request.playfabID; user.Save(); } if (user.AuthenticationLevel < AuthenticationLevel.VerifiedUser) { Console.WriteLine("Verified user: "******" signed in through game"); return(new SignInResponse() { sessionID = session.Key }); }