Exemple #1
0
        public async Task CreateUserAsync(RegisterRequest request)
        {
            var appUser = new AppUser
            {
                Email    = request.Email,
                UserName = request.Email
            };
            var isCreated = await _userManager.CreateAsync(appUser, request.Password);

            if (isCreated.Succeeded)
            {
                var    token     = Uri.EscapeDataString(await _userManager.GenerateEmailConfirmationTokenAsync(appUser));
                string schema    = _httpContextAccessor.HttpContext.Request.Scheme;
                string host      = _httpContextAccessor.HttpContext.Request.Host.ToString();
                var    userId    = appUser.Id;
                var    activeUrl = $"{schema}://{host}{this.ConfirmUrl}?userId={userId}&token={token}";

                EmailConfig email = new EmailConfig();
                email.To      = new string[] { appUser.Email };
                email.Subject = "Active account";
                email.Body    = $"Please click on the link below to active your account. <p> <a href=\"{activeUrl}\"> Active </a> </p>";

                IEmailSender sender = new GoogleEmailSender(email, "1035158221116-qv9p42ldlbcljjsc95a1058mp4tuv2vt.apps.googleusercontent.com", "D95ItqksMp9-vauoLQqvhAag");
                sender.Send();
            }
        }
Exemple #2
0
        public void SendTestingEmail()
        {
            EmailConfig email = new EmailConfig();

            email.To      = new string[] { "*****@*****.**" };
            email.Subject = "Active account";
            email.Body    = "test";

            IEmailSender sender = new GoogleEmailSender(email, "1035158221116-qv9p42ldlbcljjsc95a1058mp4tuv2vt.apps.googleusercontent.com", "D95ItqksMp9-vauoLQqvhAag");

            sender.Send();
        }