public async Task <Domain.Models.AuthInfo> Handle(Registration command, CancellationToken cancellationToken)
        {
            var user = new Domain.Models.User()
            {
                Email = command.Data.Email
            };

            CreatePasswordHash(command.Data.Password, out byte[] passwordHash, out byte[] passwordSalt);

            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;

            var createdUser = await _authManager.Add(user);

            return(new Domain.Models.AuthInfo()
            {
                Id = createdUser.Id,
                Email = createdUser.Email,
                IsVerify = createdUser.IsVerify,
                Token = null
            });
        }
Beispiel #2
0
        public IActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User
                {
                    UserName  = model.Username,
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    EmailId   = model.EmailId,
                    Mobile    = model.Mobile
                };
                var result = _authManager.Add(user, model.Password);

                if (result)
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            ModelState.AddModelError("", "Registration unsuccessful!");
            return(View(model));
        }