Ejemplo n.º 1
0
        public async Task <ActionResult> RegisterConfirmationCode(UserForConfirmationCodeDTO confirmation)
        {
            try
            {
                var memberDb = await this._repoGym.GetMember(confirmation.Email, null, 0);

                if (memberDb != null)
                {
                    return(BadRequest("Usuario ya registrado, intente hacer login"));
                }


                var codeConfirm = this._repo.GenerateConfirmationCode();

                // Envio de Correo.
                new PrometheusServicesHelper(this._appSettings).SendEmail(confirmation.Email, confirmation.MemberId, codeConfirm);

                return(Ok(codeConfirm));
            }
            catch (Exception ex)
            {
                new FileManagerHelper().RecordLogFile(MethodBase.GetCurrentMethod().ReflectedType.FullName, confirmation, ex);
                return(BadRequest(this._appSettings.Value.ServerError));
            }
        }
Ejemplo n.º 2
0
        private static bool ValidateConfirmationData(UserForConfirmationCodeDTO confirmationDto, Member memberDb, bool valid)
        {
            var gHelper = new GeneralHelper();

            valid = false;
            switch (confirmationDto.Key)
            {
            case "Birthdate":
                if (gHelper.GetOnlyNumber(memberDb.Birthdate.ToString("dd/MM/yyyy")) == gHelper.GetOnlyNumber(confirmationDto.Value))
                {
                    valid = true;
                }
                break;

            case "Phone":
                if (gHelper.GetOnlyNumber(memberDb.Phone) == gHelper.GetOnlyNumber(confirmationDto.Value))
                {
                    valid = true;
                }
                break;

            case "CellPhone":
                if (gHelper.GetOnlyNumber(memberDb.CellPhone) == gHelper.GetOnlyNumber(confirmationDto.Value))
                {
                    valid = true;
                }
                break;
            }

            return(valid);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> ResetPasswordConfirmation(UserForConfirmationCodeDTO confirmation)
        {
            try
            {
                var valid    = false;
                var memberDb = await this._repoGym.GetMember(confirmation.Email, confirmation.MemberId, 0);

                if (memberDb == null)
                {
                    return(BadRequest("Usuario no encontrado"));
                }

                // Validation Confirmation Data
                valid = ValidateConfirmationData(confirmation, memberDb, valid);

                if (!valid)
                {
                    return(BadRequest("Verificacion Invalida"));
                }


                var codeConfirm = this._repo.GenerateConfirmationCode();

                // Envio de Correo.
                new PrometheusServicesHelper(this._appSettings).SendEmail(memberDb.User.UserName, memberDb.User.DisplayName, codeConfirm);

                return(Ok(codeConfirm));
            }
            catch (Exception ex)
            {
                new FileManagerHelper().RecordLogFile(MethodBase.GetCurrentMethod().ReflectedType.FullName, confirmation, ex);
                return(BadRequest(this._appSettings.Value.ServerError));
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> ConfirmationCode(UserForConfirmationCodeDTO confirmationDto)
        {
            // Este metodo valida el usuario por el MemberId, y verifica que el Correo Enviado, no este registrado previamente.
            try
            {
                var memberDb = await this._repoGym.GetMember(null, confirmationDto.MemberId, 0);

                if (memberDb == null)
                {
                    return(BadRequest("Usuario no encontrado"));
                }

                var memberEmailDb = await this._repoGym.GetMember(confirmationDto.Email, null, 0);

                if (memberEmailDb != null)
                {
                    return(BadRequest("El correo ya se encuentra Registrado"));
                }


                var valid = false;
                // Validation Confirmation Data
                valid = ValidateConfirmationData(confirmationDto, memberDb, valid);

                if (!valid)
                {
                    return(BadRequest("Verificacion Invalida"));
                }

                var codeConfirm = this._repo.GenerateConfirmationCode();

                // Envio de Correo.
                new PrometheusServicesHelper(this._appSettings).SendEmail(memberDb.User.UserName, memberDb.User.DisplayName, codeConfirm);

                return(Ok(codeConfirm));
            }
            catch (Exception ex)
            {
                new FileManagerHelper().RecordLogFile(MethodBase.GetCurrentMethod().ReflectedType.FullName, confirmationDto, ex);
                return(BadRequest(this._appSettings.Value.ServerError));
            }
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> ResetPasswordValidation(UserForConfirmationCodeDTO toValidation)
        {
            try
            {
                var memberDb = await this._repoGym.GetMember(toValidation.MemberId, toValidation.MemberId, 0);

                if (memberDb == null)
                {
                    return(BadRequest("Usuario no encontrado"));
                }

                var lst = await this._repoGym.GetValidationTypes();

                return(Ok(new { email = memberDb.User.UserName, keys = lst.Select(v => v.Name).ToList() }));
            }
            catch (Exception ex)
            {
                new FileManagerHelper().RecordLogFile(MethodBase.GetCurrentMethod().ReflectedType.FullName, toValidation, ex);
                return(BadRequest(this._appSettings.Value.ServerError));
            }
        }