예제 #1
0
        public virtual async Task <IActionResult> Registration(RegistrationModel model)
        {
            //Service call for registering new user
            var serviceResult = await authService.RegisterUserAsync(model.UserName, model.Email, model.Password);

            if (serviceResult.Success)
            {
                //If user successfuly registered, create registration token, prepare confirmation url and send email
                IUploader uploader = serviceResult.Result;
                string    token    = await authService.CreateConfirmationTokenAsync(uploader);

                string url = urlService.CreateUrl(this, uploader.UserId, token, Name, nameof(Confirm));
                await mailService.SendRegistrationEmailAsync(uploader.UserMail, url, token);

                return(RedirectToAction(nameof(Login)));
            }

            //Display error if something went wrong
            ModelState.FillWithErrors(serviceResult.Errors);
            return(View(model));
        }