Пример #1
0
        public async Task <IHttpActionResult> CheckPin(CambioPinModel model)
        {
            try
            {
                var session = await GetSession();

                var persona = await _logicPersone.GetPersona(session);

                var currentPin = await _logicPersone.GetPin(persona);

                if (currentPin == null)
                {
                    return(BadRequest("Pin non impostato"));
                }

                if (currentPin.RichiediModificaPIN)
                {
                    return(BadRequest("E' richiesto il reset del pin"));
                }

                if (currentPin.PIN_Decrypt != model.vecchio_pin)
                {
                    return(BadRequest("Il vecchio PIN non è corretto!!!"));
                }

                return(Ok("OK"));
            }
            catch (Exception e)
            {
                Log.Error("CheckPin", e);
                return(ErrorHandler(e));
            }
        }
Пример #2
0
        public async Task CambioPin(CambioPinModel model)
        {
            await _unitOfWork.Persone.SavePin(model.PersonaUId,
                                              EncryptString(model.nuovo_pin, AppSettingsConfiguration.masterKey),
                                              false);

            await _unitOfWork.CompleteAsync();
        }
Пример #3
0
        public async Task <IHttpActionResult> CambioPin(CambioPinModel model)
        {
            try
            {
                if (model.conferma_pin != model.nuovo_pin)
                {
                    return(BadRequest("Il nuovo PIN non combacia con quello di conferma!!!"));
                }

                var session = await GetSession();

                var persona = await _logicPersone.GetPersona(session);

                var currentPin = await _logicPersone.GetPin(persona);

                if (currentPin == null)
                {
                    return(BadRequest("Pin non impostato"));
                }
                if (currentPin.RichiediModificaPIN)
                {
                    return(BadRequest("E' richiesto il reset del pin"));
                }
                if (currentPin.PIN_Decrypt != model.vecchio_pin)
                {
                    return(BadRequest("Il vecchio PIN non è corretto!!!"));
                }

                int valuePin;
                var checkTry = int.TryParse(model.nuovo_pin, out valuePin);
                if (!checkTry)
                {
                    return(BadRequest("Il pin deve contenere solo cifre numeriche"));
                }
                if (model.nuovo_pin.Length != 4)
                {
                    return(BadRequest("Il PIN dev'essere un numero di massimo 4 cifre!"));
                }

                model.PersonaUId = persona.UID_persona;

                await _logicPersone.CambioPin(model);

                return(Ok("OK"));
            }
            catch (Exception e)
            {
                Log.Error("CambioPin", e);
                return(ErrorHandler(e));
            }
        }
        public async Task <ActionResult> SalvaPin(CambioPinModel model)
        {
            try
            {
                var apiGateway = new ApiGateway(_Token);
                await apiGateway.Persone.SalvaPin(model);

                return(Json("", JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(new ErrorResponse(e.Message), JsonRequestBehavior.AllowGet));
            }
        }
Пример #5
0
        public async Task <ActionResult> SalvaPin(CambioPinModel model)
        {
            try
            {
                await ApiGateway.SalvaPin(model);

                return(Json(Url.Action("RiepilogoSedute", "Sedute"), JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(new ErrorResponse {
                    message = e.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
        public async Task SalvaPin(CambioPinModel model)
        {
            try
            {
                var requestUrl = $"{apiUrl}/persone/cambio-pin";
                var body       = JsonConvert.SerializeObject(model);

                await Post(requestUrl, body, _token);
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.Error("SalvaPin", ex);
                throw ex;
            }
            catch (Exception ex)
            {
                Log.Error("SalvaPin", ex);
                throw ex;
            }
        }