private async void SignUp_Clicked(object sender, EventArgs e) { CreateAccountError.IsVisible = false; if (string.IsNullOrEmpty(NewEmailEntry.Text) || string.IsNullOrEmpty(NewPasswordEntry.Text) || string.IsNullOrEmpty(NewPasswordConfirmEntry.Text)) { CreateAccountError.Text = "Please fill in all fields."; CreateAccountError.IsVisible = true; return; } else if (!RegexHelper.IsValidEmail(NewEmailEntry.Text)) { CreateAccountError.Text = "Please enter a valid email address."; CreateAccountError.IsVisible = true; return; } else if (string.Compare(NewPasswordEntry.Text, NewPasswordConfirmEntry.Text) != 0) { CreateAccountError.Text = "The two passwords do not match. Please try Again."; CreateAccountError.IsVisible = true; return; } else if (NewPasswordEntry.Text.Length < 8 || !NewPasswordEntry.Text.Any(char.IsDigit) || !NewPasswordEntry.Text.Any(char.IsUpper) || !NewPasswordEntry.Text.Any(char.IsLower)) { CreateAccountError.Text = "Your password must be at least 8 characters with an upercase letter, lowercase letter and a number"; CreateAccountError.IsVisible = true; return; } Loading.IsVisible = true; CognitoContext context = await _cognitoHelper.SignUp(NewEmailEntry.Text.ToLower(), NewPasswordEntry.Text); switch (context.Result) { case CognitoResult.PasswordRequirementsFailed: CreateAccountError.Text = "Your password must be at least 8 characters with an upercase letter, lowercase letter and a number"; CreateAccountError.IsVisible = true; Loading.IsVisible = false; break; case CognitoResult.UserNameAlreadyUsed: CreateAccountError.Text = "There is already an account using that email address."; CreateAccountError.IsVisible = true; Loading.IsVisible = false; break; case CognitoResult.SignupOk: Loading.IsVisible = false; CreateAccountGrid.FadeTo(0, 1000); CreateAccountGrid.IsVisible = false; ConfirmEmailGrid.IsVisible = true; ConfirmEmailGrid.FadeTo(1, 1000); break; default: CreateAccountError.Text = "Something went wrong. Please try again later."; CreateAccountError.IsVisible = true; Loading.IsVisible = false; break; } }
public void SetUp() { var credentialsOptions = new CredentialsOptions(); var credentialsProvider = new CredentialsProvider(credentialsOptions); var options = new CognitoOptions <CognitoContextTests>( ClientId: "", RegionEndpoint: "", CredentialsProfile: "", Role: "" ); _context = new CognitoContext <CognitoContextTests>(credentialsProvider, options); }
public void FunctionTest() { string testData = "{\r\n\t\"version\": \"1\",\r\n\t\"region\": \"ap-southeast-1\",\r\n\t\"userPoolId\": \"ap-southeast-1_xNdr3g62r\",\r\n\t\"userName\": \"09621d65-0c1c-4ee0-9ab6-44f7d1aba8b4\",\r\n\t\"callerContext\": {\r\n\t\t\"awsSdkVersion\": \"aws-sdk-java-console\",\r\n\t\t\"clientId\": \"2gk449k1v21b6sci549b4klssp\"\r\n\t},\r\n\t\"triggerSource\": \"PostConfirmation_ConfirmSignUp\",\r\n\t\"request\": {\r\n\t\t\"userAttributes\": {\r\n\t\t\t\"sub\": \"09621d65-0c1c-4ee0-9ab6-44f7d1aba8b4\",\r\n\t\t\t\"cognito:email_alias\": \"[email protected]\",\r\n\t\t\t\"cognito:user_status\": \"CONFIRMED\",\r\n\t\t\t\"birthdate\": \"1986-07-19\",\r\n\t\t\t\"email_verified\": \"true\",\r\n\t\t\t\"name\": \"kay weng foong\",\r\n\t\t\t\"phone_number_verified\": \"false\",\r\n\t\t\t\"phone_number\": \"+60165490075\",\r\n\t\t\t\"email\": \"[email protected]\"\r\n\t\t}\r\n\t},\r\n\t\"response\":\r\n\t{\r\n\t\r\n\t}\r\n}"; try { var function = new Function(Amazon.RegionEndpoint.APSoutheast1, "", ""); var context = new TestLambdaContext(); CognitoContext model = JsonConvert.DeserializeObject <CognitoContext>(testData); CognitoContext response = function.FunctionHandler(model, context); Assert.NotNull(response); Assert.True(response.Version == "1"); } catch (Exception ex) { throw ex; } }