public override async Task Start(string _postJson, IDynamoDBContext _dynamoDBContext) { await base.Start(_postJson, _dynamoDBContext); User user = JsonConvert.DeserializeObject <User>(_postJson); var signUpRequest = new SignUpRequest { ClientId = ApiDefine.CognitoClientId, Password = user.Password, Username = user.Email }; var emailAttribute = new AttributeType { Name = "email", Value = user.Email }; var nickNameAttribute = new AttributeType { Name = "nickname", Value = user.Name }; signUpRequest.UserAttributes.Add(emailAttribute); signUpRequest.UserAttributes.Add(nickNameAttribute); var client = new AmazonCognitoIdentityProviderClient(ApiDefine.Credentials, RegionEndpoint.USWest2); var result = await client.SignUpAsync(signUpRequest); JsPath = "cognito/sign.up.js"; string json = JsonConvert.SerializeObject(result); await loadJs(); ExecJs = ExecJs.Replace("JSON", json.Replace("\"", "\\\"")); }
public override async Task Start(string _postJson, IDynamoDBContext _dynamoDBContext) { await base.Start(_postJson, _dynamoDBContext); JsPath = "blogger/helloworld.view.js"; var search = _dynamoDBContext.ScanAsync <Comment>(null); var page = await search.GetNextSetAsync(); page.Sort((a, b) => { return(b.TimeStamp.CompareTo(a.TimeStamp)); }); string json = JsonConvert.SerializeObject(page); await loadJs(); ExecJs = ExecJs.Replace("JSON", json.Replace("\"", "\\\"")); }
public override async Task Start(string _postJson, IDynamoDBContext _dynamoDBContext) { await base.Start(_postJson, _dynamoDBContext); JsPath = "index.view.js"; List <string> projects = new List <string>() { "sample", "cognito" }; var json = JsonConvert.SerializeObject(projects); await loadJs(); ExecJs = ExecJs.Replace("JSON", json.Replace("\"", "\\\"")); }
public override async Task Start(string _postJson, IDynamoDBContext _dynamoDBContext) { await base.Start(_postJson, _dynamoDBContext); User user = JsonConvert.DeserializeObject <User>(_postJson); var authReq = new AdminInitiateAuthRequest() { UserPoolId = ApiDefine.CognitoPoolId, ClientId = ApiDefine.CognitoClientId, AuthFlow = AuthFlowType.ADMIN_NO_SRP_AUTH }; authReq.AuthParameters.Add("USERNAME", user.Email); authReq.AuthParameters.Add("EMAIL", user.Email); authReq.AuthParameters.Add("PASSWORD", user.Password); var client = new AmazonCognitoIdentityProviderClient(ApiDefine.Credentials, RegionEndpoint.USWest2); AdminInitiateAuthResponse authResp = await client.AdminInitiateAuthAsync(authReq); // AccessTokenを元にUser名を取得 var getUserReq = new GetUserRequest() { AccessToken = authResp.AuthenticationResult.AccessToken }; var getUserResp = await client.GetUserAsync(getUserReq); /*var req = new AdminRespondToAuthChallengeRequest() * { * ChallengeName = ChallengeNameType.ADMIN_NO_SRP_AUTH, * ClientId = ApiDefine.CognitoClientId, * UserPoolId = ApiDefine.CognitoPoolId, * Session = authResp.Session, * ChallengeResponses = new Dictionary<string, string>() { * { "USERNAME", user.Email }, { "PASSWORD", user.Password } * }, * }; * var resp = await client.AdminRespondToAuthChallengeAsync(req);*/ JsPath = "cognito/my.page.js"; string json = JsonConvert.SerializeObject(getUserResp); await loadJs(); ExecJs = ExecJs.Replace("_JSON", json.Replace("\"", "\\\"")); }
public override async Task Start(string _postJson, IDynamoDBContext _dynamoDBContext) { await base.Start(_postJson, _dynamoDBContext); JsPath = "blogger/add.comment.js"; var comment = JsonConvert.DeserializeObject <Comment>(_postJson); comment.Content = HttpUtility.HtmlEncode(comment.Content); comment.Id = Guid.NewGuid().ToString(); comment.TimeStamp = DateTime.Now; await _dynamoDBContext.SaveAsync <Comment>(comment); var search = _dynamoDBContext.ScanAsync <Comment>(null); var page = await search.GetNextSetAsync(); page.Sort((a, b) => { return(b.TimeStamp.CompareTo(a.TimeStamp)); }); string json = JsonConvert.SerializeObject(page); await loadJs(); ExecJs = ExecJs.Replace("JSON", json.Replace("\"", "\\\"")); }
public override async Task Start(string _postJson, IDynamoDBContext _dynamoDBContext) { await base.Start(_postJson, _dynamoDBContext); User user = JsonConvert.DeserializeObject <User>(_postJson); var signUpRequest = new ConfirmSignUpRequest { ClientId = ApiDefine.CognitoClientId, ConfirmationCode = user.Password, Username = user.Name }; var client = new AmazonCognitoIdentityProviderClient(ApiDefine.Credentials, RegionEndpoint.USWest2); var result = await client.ConfirmSignUpAsync(signUpRequest); JsPath = "cognito/confirm.js"; string json = JsonConvert.SerializeObject(result); await loadJs(); ExecJs = ExecJs.Replace("JSON", json.Replace("\"", "\\\"")); }