public async Task <LoginResult> AuthenticateAsync(GoogleAccount account, RemoteUser user)
        {
            bool validationResult = Task.Run(() => ValidateAsync(account.Token)).Result;

            if (!validationResult)
            {
                return(new LoginResult
                {
                    Status = false,
                    Message = "Access is denied"
                });
            }

            var gUser = new GoogleUserInfo
            {
                Email = account.Email,
                Name  = account.Name
            };
            var result = GoogleSignIn.SignIn(account.Email, account.OfficeId, account.Name, account.Token, user.Browser, user.IpAddress, account.Culture);

            if (result.Status)
            {
                if (!Registrations.HasAccount(account.Email))
                {
                    string template     = "~/Catalogs/{catalog}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html";
                    var    welcomeEmail = new WelcomeEmail(gUser, template, ProviderName);
                    await welcomeEmail.SendAsync();
                }
            }

            return(result);
        }
Esempio n. 2
0
        public async Task <LoginResult> AuthenticateAsync(GoogleAccount account, RemoteUser user)
        {
            bool validationResult = Task.Run(() => this.ValidateAsync(account.Token)).GetAwaiter().GetResult();

            if (!validationResult)
            {
                return(new LoginResult
                {
                    Status = false,
                    Message = Resources.AccessIsDenied
                });
            }

            var gUser = new GoogleUserInfo
            {
                Email = account.Email,
                Name  = account.Name
            };

            var result = await GoogleSignIn.SignInAsync(this.Tenant, account.Email, account.OfficeId, account.Name, account.Token, user.Browser, user.IpAddress, account.Culture).ConfigureAwait(false);

            if (result.Status)
            {
                if (!await Registrations.HasAccountAsync(this.Tenant, account.Email).ConfigureAwait(false))
                {
                    string template     = "~/Tenants/{tenant}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html";
                    var    welcomeEmail = new WelcomeEmail(gUser, template, ProviderName);
                    await welcomeEmail.SendAsync(this.Tenant).ConfigureAwait(false);
                }
            }

            return(result);
        }
Esempio n. 3
0
        public async Task <IActionResult> Get(int id)
        {
            // var v =await _context.Testdbs.FirstOrDefaultAsync(x=>x.id==id);

            // var c= new Communication(_config);
            //c.sendEmailSendgridViaLibrary();
            // c.OrangeSmsBalance();

            // var sms = new OrangeSMSProvider(_config,_memoryCache,_logger);
            //var token = sms.get_Token();
            //  sms.get_Balance();

            var wlc = new WelcomeEmail()
            {
                name                  = "jonathan djouonang",
                username              = "******",
                password              = "******",
                customerServiceEmail  = "*****@*****.**",
                customerServiceNumber = "652012457"
            };

            email.sendResetPassswordEmailSendgrid("*****@*****.**", "Djouonang", wlc);
//email.sendWelcomeEmailSendgrid("*****@*****.**","Djouonang",wlc);

            //   IEmail  email = new Email();

            //   email.sendWelcomeEmailSendgrid("*****@*****.**","Djouonang",wlc,_config,_logger);


            //sms.send_SMS("656896184", "API SMS TEST");
            return(Ok("veee"));
        }
Esempio n. 4
0
        public async Task <LoginResult> AuthenticateAsync(FacebookAccount account, RemoteUser user)
        {
            var facebookUser = this.GetFacebookUserInfo(account.Token);

            if (!this.Validate(facebookUser, account.FacebookUserId, account.Email))
            {
                return(new LoginResult
                {
                    Status = false,
                    Message = Resources.AccessIsDenied
                });
            }

            var result =
                await
                FacebookSignIn.SignInAsync(this.Tenant, account.FacebookUserId, account.Email, account.OfficeId, facebookUser.Name, account.Token, user.Browser, user.IpAddress, account.Culture)
                .ConfigureAwait(false);

            if (result.Status)
            {
                if (!await Registrations.HasAccountAsync(this.Tenant, account.Email).ConfigureAwait(false))
                {
                    string template     = "~/Tenants/{tenant}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html";
                    var    welcomeEmail = new WelcomeEmail(facebookUser, template, this.ProviderName);
                    await welcomeEmail.SendAsync(this.Tenant).ConfigureAwait(false);
                }
            }
            return(result);
        }
Esempio n. 5
0
        public async Task <LoginResult> AuthenticateAsync(FacebookAccount account, RemoteUser user)
        {
            FacebookUserInfo facebookUser = GetFacebookUserInfo(account.Token);

            if (!Validate(facebookUser, account.FacebookUserId, account.Email))
            {
                return(new LoginResult
                {
                    Status = false,
                    Message = "Access is denied"
                });
            }

            LoginResult result = FacebookSignIn.SignIn(account.FacebookUserId, account.Email, account.OfficeId, facebookUser.Name, account.Token, user.Browser,
                                                       user.IpAddress, account.Culture);

            if (result.Status)
            {
                if (!Registration.HasAccount(account.Email))
                {
                    string       template     = "~/Catalogs/{catalog}/Areas/Frapid.Account/EmailTemplates/welcome-3rd-party.html";
                    WelcomeEmail welcomeEmail = new WelcomeEmail(facebookUser, template, ProviderName);
                    await welcomeEmail.SendAsync();
                }
            }
            return(result);
        }
Esempio n. 6
0
        public static WelcomeEmail Welcome(string to, string password, string loginUrl)
        {
            WelcomeEmail email = CreateEmail <WelcomeEmail>(to, "Welcome");

            email.LoginUrl = CombineUrl(loginUrl);
            email.Password = password;
            return(email);
        }
Esempio n. 7
0
        public static void sendWelcomeEmail(this Feeder feeder)
        {
            var messaging = new MessagingService();

            var welcomeEmail = new WelcomeEmail(feeder.email, feeder.name);

            messaging.enqueueMessage(welcomeEmail);
        }
Esempio n. 8
0
        protected void btnWelcomeEmail_Click(object sender, EventArgs e)
        {
            WelcomeEmail ctrl = (WelcomeEmail)this.Page.LoadControl("/Controls/Templates/WelcomeEmail.ascx");

            ctrl.UserName = "******";
            ctrl.Password = "******";
            ctrl.SetProperties();

            phControl.Controls.Add(ctrl);
        }
Esempio n. 9
0
        public void SendWelcomeEmail([FromBody] UserViewModel user)
        {
            var ombiUser = new OmbiUser
            {
                Email    = user.EmailAddress,
                UserName = user.UserName
            };

            BackgroundJob.Enqueue(() => WelcomeEmail.SendEmail(ombiUser));
        }
Esempio n. 10
0
        public async Task <IActionResult> SendWelcomeEmail([FromBody] UserViewModel user)
        {
            var ombiUser = new OmbiUser
            {
                Alias    = user.Alias,
                Email    = user.EmailAddress,
                UserName = user.UserName
            };
            await WelcomeEmail.SendEmail(ombiUser);

            return(Ok());
        }
        /// <inheritdoc />
        public async Task Handle(UserCreatedIntegrationEvent notification, CancellationToken cancellationToken)
        {
            Maybe <User> maybeUser = await _userRepository.GetByIdAsync(notification.UserId);

            if (maybeUser.HasNoValue)
            {
                throw new DomainException(DomainErrors.User.NotFound);
            }

            User user = maybeUser.Value;

            var welcomeEmail = new WelcomeEmail(user.Email, user.FullName);

            await _emailNotificationService.SendWelcomeEmail(welcomeEmail);
        }
Esempio n. 12
0
        public async Task <ActionResult> ConfirmAsync(string token)
        {
            Guid id = token.To <Guid>();

            if (!DAL.Registration.ConfirmRegistration(id))
            {
                return(View(GetRazorView <AreaRegistration>("SignUp/InvalidToken.cshtml")));
            }

            DTO.Registration registration = DAL.Registration.Get(id);
            WelcomeEmail     email        = new WelcomeEmail(registration);
            await email.SendAsync();

            return(View(GetRazorView <AreaRegistration>("SignUp/Welcome.cshtml")));
        }
Esempio n. 13
0
        public async Task <ActionResult> ConfirmAsync(string token)
        {
            var id = token.To <Guid>();

            if (!Registrations.ConfirmRegistration(id))
            {
                return(this.View(this.GetRazorView <AreaRegistration>("SignUp/InvalidToken.cshtml")));
            }

            var registration = Registrations.Get(id);
            var email        = new WelcomeEmail(registration);
            await email.SendAsync();

            return(this.View(this.GetRazorView <AreaRegistration>("SignUp/Welcome.cshtml")));
        }
Esempio n. 14
0
        public void SendWelcomeEmail(string userName, string password, string toEmail)
        {
            var subject = _AppConfigManager.AppSettings["WelcomeSubject"];

            WelcomeEmail ctrl = (WelcomeEmail)_Page.LoadControl("/Controls/Templates/WelcomeEmail.ascx");

            ctrl.UserName = userName;
            ctrl.Password = password;
            ctrl.SetProperties();

            var body = RenderControl(ctrl);

            MailMessage mailObj = new MailMessage(_FromEmail, toEmail, subject, body);

            SendEmail(mailObj, true);
        }
Esempio n. 15
0
        //Email verification
        public async Task SendEmailVerifyCode(WelcomeEmail welcomeEmail, string code, string to)
        {
            try
            {
                using StreamReader sr = new StreamReader("EmailTemplates/VerifyEmail.html");
                string s    = sr.ReadToEnd();
                string body = s.Replace("{logo_url}", welcomeEmail.LogoUrl)
                              .Replace("{full_name}", welcomeEmail.Name)
                              .Replace("{code}", code);

                await SendEmail(to, EmailSubjectConstants.WelcomeEmail, body);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 16
0
        public async Task <bool> SendProfessionalInvitation(ProfessionalInvitationModel invitationModel)
        {
            var Token = Guid.NewGuid().ToString();

            //Send Email
            using (var emailHelper = new CummunicationHelper(Configuration))
            {
                WelcomeEmail email = new WelcomeEmail
                {
                    Name      = invitationModel.Fname,
                    VerifyUrl = invitationModel.VerifyUrl + "?invitationToken=" + Token
                };

                await emailHelper.SendEmailInvitation(email, invitationModel.Email);
            }

            return(await _userRepository.SendInvitation(invitationModel, Token));
        }
Esempio n. 17
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (_userService.EmailInUse(model.Email))
            {
                ModelState.AddModelErrorFor <RegisterViewModel>(m => m.Email, "Email is already in use by another user.");
            }

            if (IsModelValidAndPersistErrors())
            {
                User user = _userService.Register(model.Email, model.Password, Request.UserHostAddress);
                SetSuccess("Account successfully created.");
                WelcomeEmail welcomeEmail = Emailer.Welcome(user.Email, model.Password, Url.Action("Login", "Security"));
                welcomeEmail.SendAsync();
                return(RedirectToAction("Login"));
            }

            return(RedirectToSelf());
        }
Esempio n. 18
0
        public async Task <bool> SetUserEmail(string emailId, Guid userId)
        {
            Helper helper = new Helper();

            //Generate 6 digit OTP
            var      newToken = helper.CodeGenerator(6);
            DateTime expiryOn = DateTime.Now.AddMinutes(3);

            //Send Email
            using (var emailHelper = new CummunicationHelper(Configuration))
            {
                WelcomeEmail email = new WelcomeEmail
                {
                    Name = string.Empty
                };

                await emailHelper.SendEmailVerifyCode(email, newToken, emailId);
            }
            //Update to Db
            return(await _userRepository.UpdateEmail(emailId, expiryOn, newToken, userId));
        }
Esempio n. 19
0
        public async Task <ActionResult> ConfirmAsync(string token)
        {
            if (RemoteUser.IsListedInSpamDatabase(this.Tenant))
            {
                return(this.View(this.GetRazorView <AreaRegistration>("ListedInSpamDatabase.cshtml", this.Tenant)));
            }

            var id = token.To <Guid>();

            if (!await Registrations.ConfirmRegistrationAsync(this.Tenant, id).ConfigureAwait(true))
            {
                return(this.View(this.GetRazorView <AreaRegistration>("SignUp/InvalidToken.cshtml", this.Tenant)));
            }

            var registration = await Registrations.GetAsync(this.Tenant, id).ConfigureAwait(true);

            var email = new WelcomeEmail(registration);
            await email.SendAsync(this.Tenant).ConfigureAwait(true);

            return(this.View(this.GetRazorView <AreaRegistration>("SignUp/Welcome.cshtml", this.Tenant)));
        }
Esempio n. 20
0
        public async Task <Guid> RegisterAsync(User user, string verificationurl, int role)
        {
            var desiredRole = await _commonRepository.FindRoleByName(Enum.GetName(typeof(RoleType), role));

            user.Id             = Guid.NewGuid();
            user.UserProfile.Id = Guid.NewGuid();
            user.RoleId         = desiredRole.Id;

            if (!string.IsNullOrEmpty(user.Password))
            {
                var hashed = _hasher.Hash(user.Password);
                user.Password = hashed.hashed;
                user.Salt     = hashed.salt;
            }

            user.UserCode = role == 1 ? "TCC" + helper.GenerateUserCode() : "TCP" + helper.GenerateUserCode();

            var token = Guid.NewGuid().ToString();

            //Send Email
            using (var emailHelper = new CummunicationHelper(Configuration))
            {
                WelcomeEmail email = new WelcomeEmail
                {
                    Name      = string.Empty,
                    VerifyUrl = verificationurl + token
                };

                await emailHelper.SendEmailVerifyEmail(email, user.Email);
            }

            user.VerifyToken = token;
            user.TokenExpiry = DateTime.UtcNow.AddDays(1);

            var result = await _authRepository.RegisterAsync(user);

            return(result.Id);
        }
Esempio n. 21
0
        public ActionResult Index(FormCollection collection)
        {
            if (Request.Cookies["recordsubmitted"] != null)
            {
                return(View());
            }

#if DEBUG
            string randomip = RandomHelper.Instance.Next(1, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(1, 256);
#endif

            string ipaddress = "";
#if DEBUG
            ipaddress = randomip;
#else
            ipaddress = Request.UserHostAddress;
#endif
            string salutation = FormValue(collection, "salutation", "").Trim().ToProperCase();
            string gender     = salutation.ToLower() == "mr" ? "M" : "F";

            string firstname = FormValue(collection, "firstname", "GET THIS");
            string lastname  = FormValue(collection, "lastname", "GET THIS");
            string email     = FormValue(collection, "email", "GET THIS");
            string zip       = FormValue(collection, "zip", "GET THIS");
            string phone     = FormValue(collection, "phone", "GET THIS").Replace(".", "").Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "");
            string address   = FormValue(collection, "address1", "GET THIS");
            string city      = FormValue(collection, "city", "GET THIS");
            string state     = FormValue(collection, "state", "GET THIS");
            string edulevel  = FormValue(collection, "education_level", "GET THIS");
            string campaign  = FormValue(collection, "cbncampaign", "13564694"); //(collection["campaign_id"] == null || collection["campaign_id"] == "" ? "GET THIS" : collection["campaign_id"]);

            string gradyear  = FormValue(collection, "gradyear", "GET THIS");    //(collection["gradyear"] == null || collection["gradyear"] == "" ? "GET THIS" : collection["gradyear"]);
            string eduintent = FormValue(collection, "edu_intent", "GET THIS");  //(collection["edu_intent"] == null || collection["edu_intent"] == "" ? "GET THIS" : collection["edu_intent"]);
            string dobyear   = FormValue(collection, "dobyear", "");

            Random rnd      = new Random(DateTime.Now.Millisecond);
            string dobmonth = rnd.Next(1, 13).ToString();
            string dobday   = rnd.Next(1, 29).ToString();


            string utmsource = "", utmcampaign = "", utmcontent = "", utmterm = "";
            if (Request.Cookies["utm_source"] != null)
            {
                utmsource = HttpUtility.UrlDecode(Request.Cookies["utm_source"].Value);
            }
            if (Request.Cookies["utm_campaign"] != null)
            {
                utmcampaign = HttpUtility.UrlDecode(Request.Cookies["utm_campaign"].Value);
            }
            if (Request.Cookies["utm_content"] != null)
            {
                utmcontent = HttpUtility.UrlDecode(Request.Cookies["utm_content"].Value);
            }
            if (Request.Cookies["utm_term"] != null)
            {
                utmterm = HttpUtility.UrlDecode(Request.Cookies["utm_term"].Value);
            }

            int igradyear;
            int.TryParse(gradyear, out igradyear);

            String result  = "";
            String strPost = "campaign_id=" + campaign +
                             "&id=1727" +
                             "&ip=" + ipaddress +
                             "&client=20" +
                             "&salutation=" + salutation +
                             "&gender=" + gender +
                             "&firstname=" + firstname.Trim() +
                             "&lastname=" + lastname.Trim() +
                             "&email=" + email +
                             "&address1=" + address +
                             "&city=" + city +
                             "&state=" + state +
                             "&zip=" + zip +
                             "&phone=" + phone +
                             "&educationlevel=" + edulevel +
                             "&education_level=" + edulevel +
                             "&edu_intent=" + eduintent +
                             "&gradyear=" + gradyear +
                             "&dobyear=" + dobyear +
                             "&dobmonth=" + dobmonth +
                             "&dobday=" + dobday;

            if (igradyear <= DateTime.Now.Year)
            {
                //Create delayed record
                DelayedRecordClient drc = new DelayedRecordClient();
                //First check if delayed record already exists for this email
                DelayedRecord dr = drc.GetByRowKey(email.FormatEmailAsProgrammaticId());
                if (dr == null)
                {
                    drc.AddNewItem(new DelayedRecord
                    {
                        RowKey         = email.FormatEmailAsProgrammaticId(),
                        CampaignId     = campaign,
                        ClientId       = "20",
                        IP             = ipaddress,
                        Salutation     = salutation,
                        Gender         = gender,
                        FirstName      = firstname,
                        LastName       = lastname,
                        Email          = email,
                        Address1       = address,
                        City           = city,
                        State          = state,
                        Zip            = zip,
                        Phone          = phone,
                        EducationLevel = edulevel,
                        EduIntent      = eduintent,
                        GradYear       = gradyear,
                        DobYear        = dobyear,
                        DobMonth       = dobmonth,
                        DobDay         = dobday
                    });
                }
            }


            SkillCowRequestSubmissionClient rsc = new SkillCowRequestSubmissionClient();

            string mode = "external";
            if (Request.Cookies["mode"] != null)
            {
                mode = Request.Cookies["mode"].Value;
            }

            string testresults = "";
            if (Request.Cookies["testresults"] != null)
            {
                testresults = DecodeCookieCharacters(Request.Cookies["testresults"].Value);
            }

            string recommendations = "";
            if (Request.Cookies["recommendations"] != null)
            {
                recommendations = DecodeCookieCharacters(Request.Cookies["recommendations"].Value);
            }

            string careerChoicesJson = GetCareerChoicesJson();
            string data = "{\"careerchoices\":" + careerChoicesJson + "}";

            //Advertise.com variables
            string advertise_affsub        = FromCookie("AFFSUB"),
                   advertise_affiliate     = FromCookie("AFFILIATE"),
                   advertise_country       = FromCookie("COUNTRY"),
                   advertise_countrycode   = FromCookie("COUNTRYCODE"),
                   advertise_geo           = FromCookie("GEO"),
                   advertise_subid         = FromCookie("SUBID"),
                   advertise_terms_html_kw = FromCookie("TERMS_HTML_KW"),
                   advertise_terms         = FromCookie("TERMS");

            rsc.AddNewItem(new SkillCowRequestSubmission {
                Gender = gender, Salutation = salutation, State = state, City = city, Name = firstname, Zip = zip, Email = email, Phone = phone, IP = ipaddress, Mode = mode, CampaignId = campaign, TestResults = testresults, SourceForm = collection["sourceform"], GradYear = gradyear, EduIntent = eduintent, Data = data, Recommendations = recommendations, UtmSource = utmsource, UtmCampaign = utmcampaign, UtmContent = utmcontent, UtmTerm = utmterm

                , SubmissionResult = result

                , advertise_affsub        = advertise_affsub
                , advertise_affiliate     = advertise_affiliate
                , advertise_country       = advertise_country
                , advertise_countrycode   = advertise_countrycode
                , advertise_geo           = advertise_geo
                , advertise_subid         = advertise_subid
                , advertise_terms         = advertise_terms
                , advertise_terms_html_kw = advertise_terms_html_kw
            });


            AddresseeClient adc            = new AddresseeClient();
            string          emailpartition = AddresseeClient.GetPartitionKeyForEmail(email);
            Addressee       a = adc.GetByPartitionAndRowKey(emailpartition, email);
            if (a == null)
            {
                adc.AddNewItem(new Addressee(email.ToLower())
                {
                    Name = firstname, Email = email.ToLower(),
                });

                UserProfileClient upc     = new UserProfileClient();
                UserProfile       profile = new UserProfile(email.ToLower())
                {
                    Gender       = gender,
                    Salutation   = salutation,
                    FirstName    = firstname,
                    LastName     = lastname,
                    Email        = email,
                    Unsubscribed = false,
                    Zip          = zip,
                    Address1     = address,
                    City         = city,
                    State        = state,
                    Phone        = phone,
                    CampaignId   = campaign,

                    GradYear  = gradyear,
                    EduIntent = eduintent
                };
                profile.PopulateCityAndState();
                profile.SetTestResults(Request);
                profile.SetImportantThings(Request);
                profile.SetRecommendations(recommendations);
                profile.SetCareerChoices(data);
                upc.AddNewItem(profile);
            }

            WelcomeEmail.Send(Request, firstname, email, mode == "external");

            Response.Cookies["recordsubmitted"].Value   = "1";
            Response.Cookies["recordsubmitted"].Expires = DateTime.UtcNow.AddDays(90);

            Response.Cookies["ascv"].Value   = "0.20";
            Response.Cookies["ascv"].Expires = DateTime.UtcNow.AddDays(90);

            ViewBag.ThanksFlag = false;

            return(View());
        }