public async ValueTask <HttpResponseMessage> User_UpdateV1(string jwt, UserV1 model) { _http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", jwt); return(await _http.PutAsync("user/v1", new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"))); }
public IActionResult UpdateV1([FromBody] UserV1 model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = uow.Users.GetAsNoTracking(QueryExpressionFactory.GetQueryExpression <tbl_User>() .Where(x => x.Id == model.Id).ToLambda()) .SingleOrDefault(); if (user == null) { ModelState.AddModelError(MessageType.UserNotFound.ToString(), $"User:{model.Id}"); return(NotFound(ModelState)); } else if (user.IsDeletable && user.IsDeletable != model.IsDeletable) { ModelState.AddModelError(MessageType.UserImmutable.ToString(), $"User:{user.Id}"); return(BadRequest(ModelState)); } var result = uow.Users.Update(map.Map <tbl_User>(model)); uow.Commit(); return(Ok(map.Map <UserV1>(result))); }
public IActionResult UpdateV1([FromBody] UserV1 model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = uow.Users.Get(x => x.Id == GetIdentityGUID()).SingleOrDefault(); if (user == null) { ModelState.AddModelError(MessageType.UserNotFound.ToString(), $"User:{GetIdentityGUID()}"); return(NotFound(ModelState)); } if (user.Id != model.Id || !user.IsHumanBeing) { ModelState.AddModelError(MessageType.UserInvalid.ToString(), $"User:{user.Id}"); return(BadRequest(ModelState)); } var result = uow.Users.Update(map.Map <uvw_User>(model)); uow.Commit(); return(Ok(map.Map <UserV1>(result))); }
public IActionResult CreateV1NoConfirm([FromBody] UserV1 model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (uow.Users.Get(x => x.UserName == model.UserName).Any()) { ModelState.AddModelError(MessageType.UserAlreadyExists.ToString(), $"User:{model.UserName}"); return(BadRequest(ModelState)); } //ignore how these may be set in model... model.IsHumanBeing = false; model.EmailConfirmed = false; model.PhoneNumberConfirmed = false; model.PasswordConfirmed = false; if (!new ValidationHelper().ValidateEmail(model.UserName).Succeeded) { ModelState.AddModelError(MessageType.UserInvalid.ToString(), $"User:{model.UserName}"); return(BadRequest(ModelState)); } var result = uow.Users.Create(map.Map <tbl_User>(model)); uow.Commit(); return(Ok(map.Map <UserV1>(result))); }
public async ValueTask <UserV1> User_UpdateV1(UserV1 model) { var response = await Endpoints.User_UpdateV1(Grant.AccessToken.RawData, model); if (response.IsSuccessStatusCode) { return(await response.Content.ReadAsAsync <UserV1>().ConfigureAwait(false)); } throw new HttpRequestException(response.RequestMessage.ToString(), new Exception(response.ToString())); }
public static string ConfirmPassword(UserV1 user, Uri link) { /* * use http://rendera.herokuapp.com/ to test template before format... * use https://www.buildmystring.com to format template into string that compiles... */ return("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">" + "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + " <head>" + " <!--[if !mso]><!-- -->" + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" + " <style>" + " @font-face { font-family: Open Sans; src: url('http://fonts.googleapis.com/css?family=Open+Sans'); }" + " </style>" + " <!--<![endif]-->" + " <style>" + " table { color: inherit; }" + " </style>" + " </head>" + " <body style=\"font-size: 31px; font-family: 'Open Sans', 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color:#404040; padding: 0; width: 100% !important; -webkit-text-size-adjust: 100%; font-weight: 300 !important; margin: 0; -ms-text-size-adjust: 100%;\" mar=g inheight=\"0\" marginwidth=\"0\" id=\"dbx-email-body\">" + " <div style=\"max-width: 600px !important; padding: 4px;\">" + " <table cellpadding=\"0\" cellspacing=\"0\" style=\"padding: 0 45px; width: 100% !important; padding-top: 45px;border: 1px solid #F0F0F0; background-color: #FFFFFF;\" border=\"0\" align==\"center\">" + " <tr>" + " <td align=\"center\">" + " <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">" + " <tr style=\"font-size: 16px; font-weight: 300; color: #404040; font-family: 'Open Sans', 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 26px; text-align: left;\">" + " <td>" + " <br>" + " <br>Hi " + string.Format("{0} {1}", user.FirstName, user.LastName) + "." + " <br>" + " <br>Someone recently requested a password change for your account. If this was you, you can set a new password below." + " <br>" + " <br><a style= 'border-radius: 4px; font-size: 15px; color: white; text-decoration: none; padding: 14px 7px 14px 7px; width: 210px; max-width: 210px; font-family: \"Open Sans\", \"Helvetica Neue\", Arial; margin: 0; display: block; background-color: #007ee6; text-align: center;' href=" + link.AbsoluteUri + ">Change password</a>" + " <br>If you don't want to change your password or didn't request this, just ignore and delete this message." + " <br>" + " <br>To keep your account secure, please don't forward this email to anyone." + " <br>" + " </td>" + " </tr>" + " <tr>" + " <td height=\"40\"></td>" + " </tr>" + " </table>" + " </td>" + " </tr>" + " </table>" + " </div>" + " </body>" + "</html>"); }
public override int Run(string[] remainingArguments) { UserV1 user = null; try { if (_human) { user = _service.User_CreateV1( new UserV1() { UserName = _userName, Email = _userName, FirstName = _firstName, LastName = _lastName, IsLockedOut = false, IsHumanBeing = true, IsDeletable = true, }).Result; } else { user = _service.User_CreateV1NoConfirm( new UserV1() { UserName = _userName, Email = _userName, FirstName = _firstName, LastName = _lastName, IsLockedOut = false, IsHumanBeing = false, IsDeletable = true, }).Result; } _ = _service.User_AddToLoginV1(user.Id, _login.Id) .Result; FormatOutput.Users(_uow, new List <E_User> { _map.Map <E_User>(user) }); return(StandardOutput.FondFarewell()); } catch (Exception ex) { return(StandardOutput.AngryFarewell(ex)); } }
public static string ImplicitGrant(IssuerV1 issuer, AudienceV1 audience, UserV1 user, Uri link) { /* * use http://rendera.herokuapp.com/ to test template before format... * use https://www.buildmystring.com to format template into string that compiles... */ return("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">" + "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + " <head>" + " <!--[if !mso]><!-- -->" + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" + " <style>" + " @font-face { font-family: Open Sans; src: url('http://fonts.googleapis.com/css?f= amily=Open+Sans'); }" + " </style>" + " <!--<![endif]-->" + " <style>" + " table { color: inherit; }" + " </style>" + " </head>" + " <body style=\"font-size: 31px; font-family: 'Open Sans', 'Helvetica Neue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color:=#404040; padding: 0; width: 100% !important; -webkit-text-size-adjust: 100%; font-weight: 300 !important; margin: 0; -ms-text-size-adjust: 100%;\" marginheight=\"0\" marginwidth=\"0\" id=\"dbx-email-body\">" + " <div style=\"max-width: 600px !important; padding: 4px;\">" + " <table cellpadding=\"0\" cellspacing=\"0\" style=\"padding: 0 45px; width: 100% !important; padding-top: 45px;border: 1px solid #F0F0F0; background-color: #FFFFFF;\" border=\"0\" align=\"center\">" + " <tr>" + " <td align=\"center\">" + " <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">" + " <tr style=\"font-size: 16px; font-weight: 300; color: #404040; font-family: 'Open Sans', 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 26px; text-align: left;\">" + " <td>" + " <br>" + " <br>Hi " + string.Format("{0} {1}", user.FirstName, user.LastName) + "." + " <br>" + " <br>The link will log you into the application named " + audience.Name + " automatically." + " <br>" + " <br><a style=\"border-radius: 4px; font-size: 15px; color: white; text-decoration: none; padding: 14px 7px 14px 7px; width: 210px; max-width: 210px; font-family: 'Open Sans', 'Helvetica Neue', Arial; margin: 0; display: block; background-color:#007ee6; text-align: center;\" href=" + link.AbsoluteUri + ">Login now</a>" + " <br>" + " </td>" + " <tr>" + " <tr>" + " <td height=\"40\"></td>" + " </tr>" + " </table>" + " </td>" + " </tr>" + " </table>" + " </div>" + " </body>" + "</html>"); }
public async ValueTask <IActionResult> CreateV1([FromBody] UserV1 model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (uow.Users.Get(x => x.UserName == model.UserName).Any()) { ModelState.AddModelError(MessageType.UserAlreadyExists.ToString(), $"User:{model.UserName}"); return(BadRequest(ModelState)); } var issuer = uow.Issuers.Get(x => x.Id == model.IssuerId) .SingleOrDefault(); if (issuer == null) { ModelState.AddModelError(MessageType.IssuerNotFound.ToString(), $"Issuer:{model.IssuerId}"); return(NotFound(ModelState)); } //ignore how these may be set in model... model.IsHumanBeing = true; model.EmailConfirmed = false; model.PhoneNumberConfirmed = false; model.PasswordConfirmed = false; if (!new ValidationHelper().ValidateEmail(model.UserName).Succeeded) { ModelState.AddModelError(MessageType.UserInvalid.ToString(), $"User:{model.UserName}"); return(BadRequest(ModelState)); } var result = uow.Users.Create(map.Map <tbl_User>(model)); uow.Commit(); if (uow.InstanceType == InstanceContext.DeployedOrLocal || uow.InstanceType == InstanceContext.End2EndTest) { var expire = uow.Settings.Get(x => x.IssuerId == issuer.Id && x.AudienceId == null && x.UserId == null && x.ConfigKey == SettingsConstants.TotpExpire).Single(); var code = HttpUtility.UrlEncode(new PasswordTokenFactory(uow.InstanceType.ToString()) .Generate(result.UserName, TimeSpan.FromSeconds(uint.Parse(expire.ConfigValue)), result.Id.ToString(), result.SecurityStamp)); var url = UrlFactory.GenerateConfirmEmailV1(conf, result.Id.ToString(), code); var alert = ControllerContext.HttpContext.RequestServices.GetRequiredService <IAlertService>(); await alert.Enqueue_EmailV1( new EmailV1() { FromEmail = result.EmailAddress, FromDisplay = $"{result.FirstName} {result.LastName}", ToEmail = result.EmailAddress, ToDisplay = $"{result.FirstName} {result.LastName}", Subject = $"{issuer.Name} {MessageConstants.ConfirmNewUserSubject}", Body = Email.ConfirmNewUser(map.Map <IssuerV1>(issuer), map.Map <UserV1>(result), url) }); } return(Ok(map.Map <UserV1>(result))); }
internal void Save(UserV1 user) { throw new NotImplementedException(); }