public HttpResponseMessage ConfirmToken(String userId, Guid guid)
        {
            SecurityToken securityToken = SecurityTokenService.SelectByGuid(guid);

            if (securityToken.AspNetUserId != null && securityToken.AspNetUserId == userId)
            {
                DateTime now         = DateTime.UtcNow;
                TimeSpan daysElapsed = (now - securityToken.DateCreated);
                if (daysElapsed.TotalDays > 1)
                {
                    String        errorMessage = "1|Not activated in 24 hours";
                    ErrorResponse response     = new ErrorResponse(errorMessage);
                    return(Request.CreateResponse(HttpStatusCode.NotAcceptable, response));
                }
                else
                {
                    UserService.ConfirmEmail(securityToken.AspNetUserId);
                    if (!PersonService.CheckIfPerson(securityToken.AspNetUserId))
                    {
                        PersonAddRequest person = new PersonAddRequest();
                        person.Email        = securityToken.Email;
                        person.AspNetUserId = securityToken.AspNetUserId;
                        int id = PersonService.Insert(person);
                    }
                    SuccessResponse response = new SuccessResponse();
                    return(Request.CreateResponse(HttpStatusCode.OK, response));
                }
            }
            else
            {
                String        errorMessage = "2|Confirm failed";
                ErrorResponse response     = new ErrorResponse(errorMessage);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, response));
            }
        }
Esempio n. 2
0
        public HttpResponseMessage ConfirmResetToken(Guid guid)
        {
            SecurityToken securityToken = SecurityTokenService.SelectByGuid(guid);

            if (securityToken.AspNetUserId != null)
            {
                DateTime now         = DateTime.UtcNow;
                TimeSpan daysElapsed = (now - securityToken.DateCreated);
                if (daysElapsed.TotalDays > 1)
                {
                    String        errorMessage = "1|Not activated in 24 hours";
                    ErrorResponse response     = new ErrorResponse(errorMessage);
                    return(Request.CreateResponse(HttpStatusCode.NotAcceptable, response));
                }
                else
                {
                    ItemResponse <SecurityToken> response = new ItemResponse <SecurityToken>();
                    response.Item = securityToken;
                    return(Request.CreateResponse(HttpStatusCode.OK, response));
                }
            }
            else
            {
                String        errorMessage = "2|Confirm failed";
                ErrorResponse response     = new ErrorResponse(errorMessage);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, response));
            }
        }
Esempio n. 3
0
        public async Task <HttpResponseMessage> ResendConfirmationEmail(Guid guid)
        {
            SecurityToken securityToken = SecurityTokenService.SelectByGuid(guid);

            ItemResponse <Guid> response = await SendNewConfirmationEmail(securityToken.FirstName, securityToken.LastName, securityToken.Email, securityToken.AspNetUserId);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
        public HttpResponseMessage ResetPassWord(PasswordResetRequest model)
        {
            SecurityToken securityToken = SecurityTokenService.SelectByGuid(model.Guid);

            UserService.ChangePassWord(securityToken.AspNetUserId, model.Password);
            ItemsResponse <bool> response = new ItemsResponse <bool>();

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Esempio n. 5
0
        public async Task <HttpResponseMessage> ResendResetPasswordEmail(Guid guid)
        {
            SecurityToken securityToken = SecurityTokenService.SelectByGuid(guid);

            PersonBase pb = new PersonBase();

            pb.FirstName = securityToken.FirstName;
            pb.LastName  = securityToken.LastName;
            pb.Email     = securityToken.Email;

            ConfirmationEmailRequest r = new ConfirmationEmailRequest();

            r.Email = securityToken.Email;

            ItemResponse <Guid> response = await SendResetPasswordEmail(pb, r);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }