Ejemplo n.º 1
0
        public IActionResult Register(AccountRegister new_user)
        {
            using (GlobalDBContext _context = new GlobalDBContext())
            {
                string _domainurl = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}";
                // ->TODO Validation check on clinet side using Jquery or JavaScript

                // Password hashed with extra layer of security
                string password          = new_user.Password;
                CustomPasswordHasher pwd = new CustomPasswordHasher();
                // increse the size to increase secuirty but lower performance
                string salt   = pwd.CreateSalt(10);
                string hashed = pwd.HashPassword(password, salt);
                //new_user.Salt = salt;
                new_user.Password = hashed;
                // var errors = ModelState.Values.SelectMany(v => v.Errors);
                Role role    = _context.Roles.Find(new_user.UserRole);
                User theUser = new User();
                theUser.AddFromAccountRegsiter(new_user, role, salt);
                string uniqueToken = Guid.NewGuid().ToString("N").Substring(0, 6);
                theUser.UniqueToken = uniqueToken;
                _context.Users.Add(theUser);

                SendEmail email    = new SendEmail(_emailSettings);
                string    fullname = theUser.UserFirstName + " " + theUser.UserLastName;
                string    msg      = "Please verify you email account for the verification. Click on the link to verify :";
                msg += _domainurl + "/Account/ConfirmEmail?email=" + theUser.UserEmail + "&token=" + theUser.UniqueToken;

                _context.SaveChanges();
                email.SendEmailtoUser(fullname, theUser.UserEmail, "Email Verification", msg);
                ViewBag.Messsage = new_user.FirstName + " " + new_user.LastName + " successfully registered. A Email has been sent for the verfication.";
            }
            return(View());
        }
Ejemplo n.º 2
0
        public async Task <string> RegisterAccountAsync(AccountRegister accountRegister)
        {
            var user = new DbPatient
            {
                FirstName            = accountRegister.FirstName,
                LastName             = accountRegister.LastName,
                UserName             = accountRegister.PhoneNumber.ToStandardFormatPhoneNumber(),
                Email                = accountRegister.Email,
                PhoneNumber          = accountRegister.PhoneNumber.ToStandardFormatPhoneNumber(),
                PhoneNumberConfirmed = false
            };

            var result = await _userManager.CreateAsync(user, accountRegister.Password);

            if (!result.Succeeded)
            {
                throw new BusinessException(ErrorCodes.IdentityError.ToString(), result.Errors?.FirstOrDefault().Description);
            }

            await _userManager.AddToRoleAsync(user, IdentityRoles.Patient);

            var verifiedToken = await _twoFactorAuthenticationService.RequestVerifiedTokenAsync(user.PhoneNumber);

            return(verifiedToken);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> RegisterAccount([FromBody] AccountRegister account)
        {
            var client = _httpClientFactory.CreateClient("appIDUser");

            client.DefaultRequestHeaders.Add("Authorization", "Bearer " + getIAM());

            var myContent = JsonConvert.SerializeObject(account);

            var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("grant_type", "urn:ibm:params:oauth:grant-type:apikey"),
                new KeyValuePair <string, string>("apikey", "aIr9I1oFfXQTYk_6p4ddNVe8LB4wbO70YPCmADnfkAmx")
            });
            var    result        = client.PostAsync("management/v4/" + tenantId + "/cloud_directory/sign_up", byteContent).Result;
            string resultContent = result.Content.ReadAsStringAsync().Result;

            if (resultContent.Contains(account.emails[0].value))
            {
                Partner partnerRegister = new Partner();
                partnerRegister.Email       = account.emails[0].value;
                partnerRegister.Id          = Guid.NewGuid() + "";
                partnerRegister.IsDelete    = false;
                partnerRegister.NameCompany = account.userName;
                _repository.Create(partnerRegister);
                return(Ok("Dang ky thanh cong " + account.emails[0].value));
            }

            return(Ok(resultContent));
        }
Ejemplo n.º 4
0
        public ActionResult Register(AccountRegister model)
        {
            // TODO check if user already registered

            if (ModelState.IsValid)
            {
                User user = new User()
                {
                    Email      = model.Email,
                    Username   = model.Username,
                    Password   = model.Password,
                    IsActive   = true,
                    InsertedOn = DateTime.Now
                };


                var registrationResult = _userRegistrationService.RegisterUser(user);
                if (registrationResult.Success)
                {
                    _authenticationService.SignIn(user, true);
                    return(RedirectToAction("Index", "Home"));
                }

                // errors
                foreach (var error in registrationResult.Errors)
                {
                    ModelState.AddModelError("error", error);
                }
            }

            return(View(model));
        }
        public async Task <IActionResult> Create([FromBody] AccountRegister model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values.SelectMany(v => v.Errors).Select(modelError => modelError.ErrorMessage).ToList()));
            }

            var user = new ApplicationUser {
                UserName = model.Username, Email = model.Email
            };
            var result = await UserManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                var result1 = await UserManager.AddToRoleAsync(user, "User");
            }
            else
            {
                return(BadRequest(result.Errors.Select(x => x.Description).ToList()));
            }

            await SignInManager.SignInAsync(user, false);

            return(Ok());
        }
        public ActionResult Register(AccountRegister model)
        {
            var UserId = model.UserId;
            var Pwd    = model.Pwd;

            Response.Write("<script>alert('注册成功!!')</script>");
            return(Redirect("../Home/Index"));
        }
        public async Task <IActionResult> Register(UserSelect1 user)
        {
            if (ModelState.IsValid)
            {
                var newUser = new User()
                {
                    UserName  = user.Email,
                    Email     = user.Email,
                    FirstName = user.FirstName,
                    LastName  = user.LastName,
                };

                if (!await roleManager.RoleExistsAsync("ActiveUser"))
                {
                    await roleManager.CreateAsync(new IdentityRole("ActiveUser"));
                }
                if (!await roleManager.RoleExistsAsync("Admin"))
                {
                    await roleManager.CreateAsync(new IdentityRole("Admin"));
                }

                var result = await userManager.CreateAsync(newUser, user.Password);

                if (result.Succeeded)
                {
                    var login = await signInManager.PasswordSignInAsync(user.Login, user.Password, true, false);

                    if (login.Succeeded)
                    {
                        await userManager.AddToRoleAsync(await userManager.FindByNameAsync(user.Login), "ActiveUser");

                        await userManager.AddToRoleAsync(await userManager.FindByNameAsync(user.Login), "Admin");

                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Nie można się zalogować!");
                    }
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                }
            }

            AccountRegister accountRegister = new AccountRegister()
            {
                User = user
            };

            return(View(accountRegister));
        }
        public async Task <ResultModel <AccountBasic> > RegisterAccountAsync(AccountRegister accountRegister)
        {
            var result = new ResultModel <AccountBasic>();

            try
            {
                var id_User = _tokenRead.GetValue("Id_User");
                if (!string.IsNullOrEmpty(id_User) && int.TryParse(id_User, out int userId))
                {
                    var account = new Core.Models.Account(accountRegister);
                    var valid   = account.Valid();
                    if (valid.Success)
                    {
                        await _account.RegisterAccount(account, userId);

                        if (account.Id > 0)
                        {
                            await _bus.PublishForgetAsync(new AccountCommandInsert {
                                AccountId = account.Id
                            });

                            result.SetData(new AccountBasic
                            {
                                Active         = account.Active,
                                Id             = account.Id,
                                Identification = account.Identification
                            });
                        }
                        else
                        {
                            result.NotValid();
                            result.SetMessages("Não foi possíovel realizar o cadastro!");
                        }
                    }
                    else
                    {
                        result.NotValid();
                        result.SetMessages(valid.Messages);
                    }
                }
                else
                {
                    result.NotValid();
                    result.SetMessages("Error Token, not found User_Id");
                }
            }
            catch (Exception e)
            {
                result.NotValid(e.GetBaseException().Message);
            }

            return(result);
        }
Ejemplo n.º 9
0
        public async Task <JsonResult> Register(AccountRegister account)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { success = false }));
            }

            var user = new Usuario()
            {
                UserName       = account.EmailRegister,
                Nome           = account.Nome,
                Apelido        = account.Apelido ?? account.Nome.Split(' ', StringSplitOptions.None)[0],
                DataNascimento = account.DataNascimento,
                Email          = account.EmailRegister,
                EmailConfirmed = false
            };

            var result = await userManager.CreateAsync(user, account.SenhaRegister);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    // Lista de erros do UserManager
                    // https://stackoverflow.com/questions/40583707/list-of-error-cases-in-use-usermanager-createasyncuser-password

                    if (error.Code == "DuplicateEmail")
                    {
                        return(Json(data: "5"));
                    }
                }
                return(Json(data: "6"));
            }

            await userManager.AddToRoleAsync(user, "Visitante");

            //await signInManager.PasswordSignInAsync(account.EmailRegister, account.SenhaRegister, false, lockoutOnFailure: true);

            var token = await userManager.GenerateEmailConfirmationTokenAsync(user);

            var    link     = Url.Action("ConfirmEmail", "Account", new { token, email = user.Email }, Request.Scheme);
            string logo     = "https://i.postimg.cc/4dgFYMZL/logo.png";
            string img      = "https://i.postimg.cc/x8kjcc93/Confirm.png";
            var    mensagem = string.Format("<body class='clean-body' style='margin: 0; padding: 0; -webkit-text-size-adjust: 100%; background-color: #f8f8f9;'><table bgcolor='#f8f8f9' cellpadding='0' cellspacing='0' class='nl-container' role='presentation' style='table-layout: fixed; vertical-align: top; min-width: 320px; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f8f8f9; width: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td style='word-break: break-word; vertical-align: top;' valign='top'><div style='background-color:#f39f0b;'><div class='block-grid' style='min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: #f39f0b;'><div style='border-collapse: collapse;display: table;width: 100%;background-color:#f39f0b;'><div class='col num12' style='min-width: 320px; max-width: 640px; display: table-cell; vertical-align: top; width: 640px;'><div class='col_cont' style='width:100% !important;'><div style='border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:0px; padding-bottom:0px; padding-right: 0px; padding-left: 0px;'><table border='0' cellpadding='0' cellspacing='0' class='divider' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td class='divider_inner' style='word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;' valign='top'><table align='center' border='0' cellpadding='0' cellspacing='0' class='divider_content' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 4px solid #F39F0B; width: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td style='word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top'><span></span></td></tr></tbody></table></td></tr></tbody></table></div></div></div></div></div></div><div style='background-color:#fff;'><div class='block-grid' style='min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: #fff;'><div style='border-collapse: collapse;display: table;width: 100%;background-color:#fff;'><div class='col num12' style='min-width: 320px; max-width: 640px; display: table-cell; vertical-align: top; width: 640px;'><div class='col_cont' style='width:100% !important;'><div style='border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:0px; padding-bottom:0px; padding-right: 0px; padding-left: 0px;'><div align='center' class='img-container center autowidth' style='padding-right: 0px;padding-left: 0px;'><div style='font-size:1px;line-height:22px'> </div><img align='center' alt='I'm an image' border='0' class='center autowidth' src='{0}' style='text-decoration: none; -ms-interpolation-mode: bicubic; height: auto; border: 0; width: 100%; max-width: 149px; display: block;' title='I'm an image' width='149'/><div style='font-size:1px;line-height:25px'> </div></div></div></div></div></div></div></div><div style='background-color:transparent;'><div class='block-grid' style='min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: #f8f8f9;'><div style='border-collapse: collapse;display: table;width: 100%;background-color:#f8f8f9;'><div class='col num12' style='min-width: 320px; max-width: 640px; display: table-cell; vertical-align: top; width: 640px;'><div class='col_cont' style='width:100% !important;'><div style='border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;'><table border='0' cellpadding='0' cellspacing='0' class='divider' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td class='divider_inner' style='word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 20px; padding-right: 20px; padding-bottom: 20px; padding-left: 20px;' valign='top'><table align='center' border='0' cellpadding='0' cellspacing='0' class='divider_content' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid #BBBBBB; width: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td style='word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top'><span></span></td></tr></tbody></table></td></tr></tbody></table></div></div></div></div></div></div><div style='background-color:transparent;'><div class='block-grid' style='min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: #fff;'><div style='border-collapse: collapse;display: table;width: 100%;background-color:#fff;'><div class='col num12' style='min-width: 320px; max-width: 640px; display: table-cell; vertical-align: top; width: 640px;'><div class='col_cont' style='width:100% !important;'><div style='border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:0px; padding-bottom:0px; padding-right: 0px; padding-left: 0px;'><table border='0' cellpadding='0' cellspacing='0' class='divider' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td class='divider_inner' style='word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 60px; padding-right: 0px; padding-bottom: 12px; padding-left: 0px;' valign='top'><table align='center' border='0' cellpadding='0' cellspacing='0' class='divider_content' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid #BBBBBB; width: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td style='word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top'><span></span></td></tr></tbody></table></td></tr></tbody></table><div align='center' class='img-container center fixedwidth' style='padding-right: 40px;padding-left: 40px;'><img align='center' alt='I'm an image' border='0' class='center fixedwidth' src='{1}' style='text-decoration: none; -ms-interpolation-mode: bicubic; height: auto; border: 0; width: 100%; max-width: 352px; display: block;' title='I'm an image' width='352'/></div><table border='0' cellpadding='0' cellspacing='0' class='divider' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td class='divider_inner' style='word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 50px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;' valign='top'><table align='center' border='0' cellpadding='0' cellspacing='0' class='divider_content' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid #BBBBBB; width: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td style='word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top'><span></span></td></tr></tbody></table></td></tr></tbody></table><div style='color:#555555;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.2;padding-top:10px;padding-right:40px;padding-bottom:10px;padding-left:40px;'><div style='line-height: 1.2; font-size: 12px; color: #555555; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 14px;'><p style='font-size: 30px; line-height: 1.2; text-align: center; word-break: break-word; mso-line-height-alt: 36px; margin: 0;'><span style='font-size: 30px; color: #2b303a;'><strong>Confirmação de E-mail</strong></span></p></div></div><div style='color:#555555;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;line-height:1.5;padding-top:10px;padding-right:40px;padding-bottom:10px;padding-left:40px;'><div style='line-height: 1.5; font-size: 12px; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; color: #555555; mso-line-height-alt: 18px;'><p style='font-size: 15px; line-height: 1.5; text-align: center; word-break: break-word; font-family: Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif; mso-line-height-alt: 23px; margin: 0;'><span style='color: #808389; font-size: 15px;'>Muito obrigado {2} por se inscrever em nosso website. Antes que você possa continuar é preciso confirmar seu E-mail!</span></p></div></div><div align='center' class='button-container' style='padding-top:15px;padding-right:10px;padding-bottom:0px;padding-left:10px;'><a href='{3}' style='text-decoration:none;display:inline-block;color:#ffffff;background-color:#f4b13c;border-radius:60px;-webkit-border-radius:60px;-moz-border-radius:60px;width:auto; width:auto;;border-top:1px solid #f4b13c;border-right:1px solid #f4b13c;border-bottom:1px solid #f4b13c;border-left:1px solid #f4b13c;padding-top:15px;padding-bottom:15px;font-family:Montserrat, Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;text-align:center;mso-border-alt:none;word-break:keep-all;'><span style='padding-left:30px;padding-right:30px;font-size:16px;display:inline-block;'><span style='font-size: 16px; margin: 0; line-height: 2; word-break: break-word; mso-line-height-alt: 32px;'><strong>Confirmar meu E-mail</strong></span></span></a></div><table border='0' cellpadding='0' cellspacing='0' class='divider' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td class='divider_inner' style='word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 60px; padding-right: 0px; padding-bottom: 12px; padding-left: 0px;' valign='top'><table align='center' border='0' cellpadding='0' cellspacing='0' class='divider_content' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid #BBBBBB; width: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td style='word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top'><span></span></td></tr></tbody></table></td></tr></tbody></table></div></div></div></div></div></div><div style='background-color:transparent;'><div class='block-grid' style='min-width: 320px; max-width: 640px; overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; Margin: 0 auto; background-color: #f8f8f9;'><div style='border-collapse: collapse;display: table;width: 100%;background-color:#f8f8f9;'><div class='col num12' style='min-width: 320px; max-width: 640px; display: table-cell; vertical-align: top; width: 640px;'><div class='col_cont' style='width:100% !important;'><div style='border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;'><table border='0' cellpadding='0' cellspacing='0' class='divider' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td class='divider_inner' style='word-break: break-word; vertical-align: top; min-width: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; padding-top: 20px; padding-right: 20px; padding-bottom: 20px; padding-left: 20px;' valign='top'><table align='center' border='0' cellpadding='0' cellspacing='0' class='divider_content' role='presentation' style='table-layout: fixed; vertical-align: top; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-top: 0px solid #BBBBBB; width: 100%;' valign='top' width='100%'><tbody><tr style='vertical-align: top;' valign='top'><td style='word-break: break-word; vertical-align: top; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;' valign='top'><span></span></td></tr></tbody></table></td></tr></tbody></table></div></div></div></div></div></div></td></tr></tbody></table></body>", logo, img, user.Apelido, link);
            var    email    = new EmailSender();
            await email.Mail(account.EmailRegister, "*****@*****.**", "Confirmação de E-mail", mensagem);

            return(Json(new { data = "7", usuario = user.Apelido }));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public JsonResult Register(AccountRegister account)
        {
            ResultInfo info        = new ResultInfo();
            int        companyId   = CommonMethod.GetInt(ConfigSetting.eeeYoooId);
            string     companyName = ConfigSetting.eeeYoooName;

            account.PassWord = CommonMethod.PasswordMD5(account.PassWord);
            if (AccountDBOperate.GetAccountByMobile(account.Telephone, account.Role))
            {
                info.Message = "手机号已注册";
                return(Json(info));
            }
            if (AccountDBOperate.GetAccountByEmail(account.Email, account.Role))
            {
                info.Message = "邮箱已注册";
                return(Json(info));
            }
            info.IsSuccess = AccountDBOperate.AddAccount(new Dto.CustomerCompany()
            {
                CompanyId   = companyId,
                CompanyName = companyName,
                Address     = account.CompanyAddress,
                City        = account.City,
                Infos       = account.CompanyInfo,
                Name        = account.CompanyName,
                Status      = CustomerCompanyStatusEnum.NotStart.ToString(),
                CreateBy    = account.Name,
            }, new CustomerMember()
            {
                CompanyId   = companyId,
                CompanyName = companyName,
                Email       = account.Email,
                Mobile      = account.Telephone,
                Name        = account.Name,
                CreateBy    = account.Name,
            }, new Account()
            {
                AccountName = account.Name,
                Mobile      = account.Telephone,
                Password    = account.PassWord,
                Email       = account.Email,
                Role        = account.Role,
                CreateBy    = account.Name,
            });
            return(Json(info));
        }
Ejemplo n.º 11
0
        public async Task <AuthenticationResult> RegisterAsync(AccountRegister register)
        {
            if (register == null)
            {
                throw new ArgumentNullException(nameof(register));
            }

            var acct = await _repo.LoadByEmailAsync(register.EmailAddress);

            if (acct != null)
            {
                throw new RegistrationException(acct.Id.ToString());
            }

            var cuenta = new Account
            {
                EmailAddress = register.EmailAddress,
                Password     = register.Password,
                SsoToken     = register.SsoToken,
                SsoProvider  = register.SsoProvider,
                Role         = ScoutAccountRole.Basic,
                FirstName    = register.FirstName,
                LastName     = register.LastName
            };

            Guid guid = await _repo.SaveAsync(cuenta);

            var result = new AuthenticationResult();

            if (guid != Guid.Empty)
            {
                cuenta = await _repo.LoadByEmailAsync(register.EmailAddress);

                string token = GenerateJwt(cuenta);
                result.Token = token;
                result.AuthenticationMessage = "Success";
            }
            else
            {
                result.AuthenticationMessage = "Account failed to register";
            }
            return(result);
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Register(AccountRegister model)
        {
            DBHelper db     = new DBHelper();
            var      UserId = model.UserId;
            var      Pwd    = model.Pwd;

            //判断用户名是否存在
            if (!db.UserExist(UserId))
            {
                var cmd = "Insert into UserAccount(UserId,Pwd) values('" + UserId + "','" + Pwd + "')";
                db.SqlExcute(cmd);
                return(Redirect("Login"));
            }
            else
            {
                Response.Write("<script>alert('账号已存在~~~ ')</script>");
                return(View());
            }
        }
Ejemplo n.º 13
0
        public List <AccountRegister> getpartialWalletAmt(string cPName)
        {
            SqlCommand dinsert = new SqlCommand("usp_GetWalletForCP");

            if (!string.IsNullOrWhiteSpace(cPName))
            {
                dinsert.Parameters.AddWithValue("@CPName", SqlDbType.Int).Value = cPName;
            }
            DataSet dtList = objcon.GetDsByCommand(dinsert);
            List <AccountRegister> list1 = new List <AccountRegister>();

            foreach (DataRow dr in dtList.Tables[0].Rows)
            {
                AccountRegister pd = new AccountRegister();
                // BankDetails list1 = new BankDetails();
                pd.WalletAmount = (dr["WalletAmount"].ToString());

                list1.Add(pd);
            }
            return(list1);
        }
Ejemplo n.º 14
0
        public async Task Create()
        {
            var accountRegister = new AccountRegister
            {
                FirstName = FirstName,
                LastName  = LastName,
                Email     = Email,
                UserName  = UserName,
                Password  = Password
            };

            var result = await _accountService.Register(accountRegister);

            if (!result.Succeeded)
            {
                MapErrorsToViewModel(result.Errors);
                Context.FailOnInvalidModelState();
            }

            Context.RedirectToRoute(Routes.ConfirmEmail);
        }
        public async Task Register(AccountRegister account)
        {
            AccountError error = _accountService.Register(account);

            if (error != AccountError.NoError)
            {
                await Clients.Caller.AuthenticateFailed(error);
            }
            else
            {
                Account acc = _unitOfWork.Account.GetByEmail(account.Email);

                await Clients.Caller.Authenticated(new AuthenticateResponse()
                {
                    Email       = account.Email,
                    Token       = Utility.GenerateJwtToken(acc),
                    Permissions = Utility.GetPermissionsFromRoles(acc.Roles)
                });

                Context.Items["account"] = acc;
            }
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> RegisterAsync(AccountRegister register)
        {
            var regResult = await _service.RegisterAsync(register);

            ApiResponse <string> response     = new ApiResponse <string>();
            IActionResult        actionResult = null;

            if (!string.IsNullOrEmpty(regResult.Token))
            {
                response.Result       = Core.OperationResult.Success;
                response.ResponseBody = regResult.Token;
                actionResult          = Ok(response);
            }
            else
            {
                response.Result  = Core.OperationResult.Error;
                response.Message = regResult.AuthenticationMessage;
                actionResult     = StatusCode((int)HttpStatusCode.Unauthorized, response);
            }

            return(actionResult);
        }
        public async Task <IActionResult> RegisterAccount([FromBody] AccountRegister account)
        {
            var client = _httpClientFactory.CreateClient("appIDUser");

            client.DefaultRequestHeaders.Add("Authorization", "Bearer " + getIAM());

            var myContent = JsonConvert.SerializeObject(account);

            var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("grant_type", "urn:ibm:params:oauth:grant-type:apikey"),
                new KeyValuePair <string, string>("apikey", "aIr9I1oFfXQTYk_6p4ddNVe8LB4wbO70YPCmADnfkAmx")
            });
            var    result        = client.PostAsync("management/v4/" + tenantId + "/cloud_directory/sign_up", byteContent).Result;
            string resultContent = result.Content.ReadAsStringAsync().Result;



            return(Ok(resultContent));
        }
        }                                                    // Needs public for bindings

        public AccountRegisterPage()
        {
            InitializeComponent();
            AccountRegister = new AccountRegister(); // We can only bind on the view if the object exists
            BindingContext  = this;
        }
Ejemplo n.º 19
0
        public async Task <Models.Account> RegisterAccount(AccountRegister accountRegister)
        {
            var result = await _accountRepository.RegisterAccount(accountRegister);

            return(result);
        }
Ejemplo n.º 20
0
 public async Task <IActionResult> Post(AccountRegister account)
 {
     return(Ok(await _account.RegisterAccountAsync(account)));
 }
Ejemplo n.º 21
0
 public IActionResult CreateInternController(AccountRegister new_user)
 {
     using (GlobalDBContext _context = new GlobalDBContext())
     {
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            Console.WriteLine("Loading configuration...");
            var config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                         .Build();

            Configuration = config;
            Console.WriteLine("Done...");

            Console.WriteLine("Registering IoC components...");
            var builder = SetupIoc();

            IContainer container = builder.Build(Autofac.Builder.ContainerBuildOptions.IgnoreStartableComponents);

            Mapper.Initialize(cfg =>
            {
                cfg.AddProfile(new DatabaseModelMap());
            });
            Console.WriteLine("Done");

            var mongo = container.Resolve <IMongoDatabase>();

            Console.WriteLine("Creating tables...");
            var tableSetup = new TableSetup(mongo);

            Task.Run(async() =>
            {
                bool tableResult = await tableSetup.CreateAccountCollection();
                if (tableResult)
                {
                    tableResult = await tableSetup.CreatePlayerCollection();
                }
                if (tableResult)
                {
                    tableResult = await tableSetup.CreateScoutingReportCollection();
                }
                if (tableResult)
                {
                    tableResult = await tableSetup.CreateTeamCollection();
                }

                if (!tableResult)
                {
                    throw new InvalidProgramException("Table creation failed. Review table(s) not created and exceptions generated");
                }
            }).Wait();
            Console.WriteLine("Done");

            Console.WriteLine("Creating master account...");
            var svc        = container.Resolve <IAccountService>();
            var masterAcct = new AccountRegister
            {
                EmailAddress = "*****@*****.**",
                FirstName    = "System",
                LastName     = "Admin",
                Password     = "",
                SsoProvider  = SingleSignOnProvider.None
            };

            Task.Run(async() =>
            {
                var cuenta = await svc.LoadByEmail(masterAcct.EmailAddress);
                if (cuenta == null)
                {
                    var authentication = await svc.RegisterAsync(masterAcct);
                    Console.WriteLine(authentication.AuthenticationMessage);
                }
            }).Wait();
            Console.WriteLine("All done.");
            Console.ReadKey();
        }
Ejemplo n.º 23
0
        public ActionResult Register()
        {
            AccountRegister model = new AccountRegister();

            return(View(model));
        }
Ejemplo n.º 24
0
        public async Task <Account> RegisterAccount(AccountRegister accountRegister)
        {
            var result = await _service.PostRequest <Account>(string.Format("{0}/user/create", Constants.ApiUrlBase), accountRegister);

            return(result);
        }
 public Account(AccountRegister register)
 {
     Identification = register.Identification;
     Active         = register.Active;
 }
        public AccountError Register(AccountRegister account)
        {
            if (!Messages.Utility.IsValidEmail(account.Email))
            {
                return(AccountError.InvalidEmail);
            }

            if (account.FirstName.Length <= 1)
            {
                return(AccountError.FirstNameTooShort);
            }
            if (account.FirstName.Length > 50)
            {
                return(AccountError.FirstNameTooLong);
            }

            if (account.LastName.Length <= 1)
            {
                return(AccountError.LastNameTooShort);
            }
            if (account.LastName.Length > 50)
            {
                return(AccountError.LastNameTooLong);
            }

            if (account.Password.Length <= 7)
            {
                return(AccountError.PasswordTooShort);
            }
            if (account.Password.Length > 50)
            {
                return(AccountError.PasswordTooLong);
            }

            if (!account.Password.Any(char.IsUpper))
            {
                return(AccountError.InvalidPasswordCharacters);
            }
            if (!account.Password.Any(char.IsLower))
            {
                return(AccountError.InvalidPasswordCharacters);
            }
            if (!(account.Password.Any(char.IsNumber) || new Regex("[^a-z0-9]").IsMatch(account.Password)))
            {
                return(AccountError.InvalidPasswordCharacters);
            }

            Account tmp = _unitOfWork.Account.GetByEmail(account.Email);

            if (_unitOfWork.Account.GetByEmail(account.Email) != null)
            {
                if (tmp.Roles.Any(role => role.Name == "Guest"))
                {
                    tmp.FirstName = account.FirstName;
                    tmp.LastName  = account.LastName;
                    tmp.Password  = Argon2.Hash(account.Password);
                    tmp.Roles     = new List <Role>()
                    {
                        _unitOfWork.Role.GetByName("Member")
                    };
                }
                else
                {
                    return(AccountError.EmailInUse);
                }
            }
            else
            {
                _unitOfWork.Account.Add(new Account()
                {
                    Email     = account.Email,
                    FirstName = account.FirstName,
                    LastName  = account.LastName,
                    Password  = Argon2.Hash(account.Password),
                    Roles     = new List <Role>()
                    {
                        _unitOfWork.Role.GetByName("Member")
                    }
                });
            }

            _unitOfWork.SaveChanges();

            return(AccountError.NoError);
        }
Ejemplo n.º 27
0
        static void Main(string[] args)
        {
            People temporaryPeople = new People();
            bool   isActive        = true;
            string key;

            do
            {
                Console.Clear();
                Console.WriteLine("1. Зарегистрировать пользователя \n2. Войти в ЛК \n3. Создать накладную \n4. Принять по накладной \n5. Выдать по накладной");
                key = Console.ReadLine();
                switch (key)
                {
                case "1":
                {
                    Console.WriteLine("Введите ваше имя");
                    string peopleName = Console.ReadLine();
                    temporaryPeople.Name = peopleName;
                    Console.WriteLine(temporaryPeople.Name + " Являетесь ли вы кладовщиком нашего склада (да/нет)?");
                    string action = Console.ReadLine();
                    if (action.ToLower().Contains("да"))
                    {
                        Account         temporaryAccount = new Account();
                        AccountRegister register         = new AccountRegister();
                        temporaryAccount.Name = temporaryPeople.Name;
                        register.Registration(temporaryAccount);
                    }
                    else if (action.ToLower().Contains("нет"))
                    {
                        Console.WriteLine("Вы не можете зарегистрироваться так как Вы не наш кладовщик!!!");
                    }
                }
                break;

                case "2":
                {
                    Document temporaryDocument = new Document();
                    Console.WriteLine("Введите номер выписываемой накладной");
                    string docNumber = Console.ReadLine();
                    temporaryDocument.DocumentNumber = docNumber;
                    bool isExit = false;
                    while (!isExit)
                    {
                        Item temporaryItem = new Item();
                        Console.WriteLine("Введите наименование това");
                        temporaryItem.Name = ""
                    }
                }
                break;

                case "3":
                {
                }

                break;

                case "4":
                {
                }
                break;

                case "5":
                {
                    isActive = false;
                }
                break;
                }

                Console.ReadLine();
            } while (isActive != false);
        }
Ejemplo n.º 28
0
        private void btnKontohantering_Click(object sender, RoutedEventArgs e)
        {
            AccountRegister accountRegister = new AccountRegister();

            accountRegister.ShowDialog();
        }