public HttpResponseMessage ForgottenTokenAndEmail(ForgottenPasswordEmailTokenAddRequest model)
        {
            ItemResponse <string> response = new ItemResponse <string>();

            response.Item = _svc.ForgotPasswordSendEmail(model);
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #2
0
        public string ForgotPasswordSendEmail(ForgottenPasswordEmailTokenAddRequest model)
        {

            SecurityTokenService sts = new SecurityTokenService(_dataProvider);
            SecurityTokenAddRequest star = new SecurityTokenAddRequest()
            {
                TokenTypeId = 2,
                UserEmail = model.Email
            };
            System.Guid tokenGuid = sts.Insert(star);

            var source = "http://sawubona.dev/";
            var message =
                 "<body style='margin: 0; padding: 0; background:#ccc;'><table cellpadding=0 cellspacing=0 style='width: 100%;'><tr><td style='padding: 12px 2%;'><table cellpadding=0 cellspacing=0 style='margin:auto; background: #fff; width: 96%;'><tr><td style='padding: 12px 2%;'><div><h1 style='color:white;background-color:#1E90FF;'>Youth Mentoring Connection</h1></div > <div><h2 style='margin-top: 0;'>Password Reset</h2><p>To reset your password please click the link below:<br/></br> <span style='text-align:center; margin:0;'><a href="
                 + source + "forgottenPasswords?guid="
                 + tokenGuid + "/" + model.Email + ">Click Here To Reset Password</a></p><p>...</p></div><div><h4 style='margin-top: 0;'>Sawubona!</h4><p></p></div><div style='border-top: solid 1px #ccc;'><p></p></div></td ></tr ></table ></td ></tr ></table ></body >";

            ConfirmationEmailService ces = new ConfirmationEmailService();
            ConfirmationEmailRequest cer = new ConfirmationEmailRequest()
            {
                From = "*****@*****.**",
                To = model.Email,
                Subject = "YMC Confirmation",
                Body = message
            };
            Task<bool> email = ces.Execute(cer);

            return model.Email;
        }