示例#1
0
        public async Task <HttpResponseMessage> SendVerificationMail()
        {
            HttpResponseMessage response = Request.CreateResponse();
            var email = new TApiAuth().GetLoggedInUsername(Request);

            if (string.IsNullOrEmpty(email))
            {
                response.StatusCode = System.Net.HttpStatusCode.Unauthorized;
                return(response);
            }
            else
            {
                //generating code for verification of email id
                string code = Guid.NewGuid().ToString();
                var    host = Request.RequestUri.Scheme + "://" + Request.RequestUri.Host + ":" + Request.RequestUri.Port;
                _emailComManager = new EmailComManager(host);
                string             connectionstring = ConfigurationManager.AppSettings["dbconnectionstring"];
                IdentityValidation idv = new IdentityValidation(connectionstring);
                idv.UpdateAccountActivationCode(email, code);
                var user = _userManager.GetUserFromMailId(email);
                //user.VerificationCode = code;
                //_userManager.UpdateUserProperties(user.Id, user);
                await _emailComManager.SendAccountVerificationLink((string)email, (string)user.Name, code);

                response.StatusCode = System.Net.HttpStatusCode.OK;
                return(response);
            }
        }
示例#2
0
        public async Task <HttpResponseMessage> Signup([FromBody] dynamic userinfo)
        {
            var host = Request.RequestUri.Scheme + "://" + Request.RequestUri.Host + ":" + Request.RequestUri.Port;

            _emailComManager = new EmailComManager(host);
            string             connectionstring = ConfigurationManager.AppSettings["dbconnectionstring"];
            IdentityValidation idv        = new IdentityValidation(connectionstring);
            var            resp           = new HttpResponseMessage();
            UserCredential userCredential = new UserCredential()
            {
                username = userinfo.email, password = userinfo.password
            };

            if (idv.UserExist(userCredential))
            {
                string error1 = "error: user already exist with same email id. Try resetting password.";
                resp.StatusCode   = System.Net.HttpStatusCode.NotModified;
                resp.ReasonPhrase = error1;
            }
            else
            {
                //generating code for verification of email id
                string code = Guid.NewGuid().ToString();

                // reegister user
                idv.RegisterUser(userinfo, code);

                resp.StatusCode   = System.Net.HttpStatusCode.OK;
                resp.ReasonPhrase = "User successfully created.";

                await _emailComManager.SendAccountVerificationLink((string)userinfo.email, (string)userinfo.name, code);
            }

            // show message to check inbox for activation link.

            return(resp);
        }