Exemplo n.º 1
0
        public async Task <int> RequestPasswordReset([FromBody] ResetRequest request)
        {
            try
            {
                if (request == null)
                {
                    throw new ArgumentNullException(nameof(request));
                }
                if (string.IsNullOrEmpty(request.Email))
                {
                    throw new ArgumentNullException(nameof(request), "Email is required");
                }


                var user = (await _userService.SearchUser(request.Email)).FirstOrDefault();

                if (user == null)
                {
                    _logger.LogInformation("Can't find user with email: {email}", request.Email);
                    throw new ArgumentOutOfRangeException(nameof(request), "Invalid Request");
                }

                var reset = await _userService.RequestPasswordReset(user.Id);

                return(reset);
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message, e);
                throw;
            }
        }
        public ResetReturn Any(ResetRequest request)
        {
            var returnLog = new ResetReturn();

            returnLog.OperationLog = new List<string>();

            returnLog.OperationLog.Add("Config reset started on " + DateTime.Now.ToShortTimeString() + ".");

            if (request.ResetKey.IsEqualWithCase("PrettyPleaseResetTheSystemAndDestroyAllData123"))
            {
                using (var db = DbConnectionFactory.OpenDbConnection())
                {
                    db.CreateTable<AddressDB>(true);
                    returnLog.OperationLog.Add("Created Address.");
                    db.CreateTable<TypeOfWorkDB>(true);
                    returnLog.OperationLog.Add("Created TypeOfWork.");
                    db.CreateTable<ImageOfInterestDB>(true);
                    returnLog.OperationLog.Add("Created ImageOfInterest.");
                    db.CreateTable<LocationOfInterestDB>(true);
                    returnLog.OperationLog.Add("Created LocationOfInterest.");
                    db.CreateTable<UserDB>(true);
                    returnLog.OperationLog.Add("Created User.");
                }
            }
            else
            {
                returnLog.OperationLog.Add("Invalid Key.");
            }
            return returnLog;
        }
Exemplo n.º 3
0
        private IEnumerator ResetPermissions()
        {
            var entitiesId = _campaign.activeMap.selectedEntities.Select(x => x.id).ToList();

            if (!entitiesId.Any())
            {
                yield break;
            }

            var data = new ResetRequest {
                entities = entitiesId
            };
            var url = $"{Server.baseUrl}/world/campaign/{Campaign.campaignId}" +
                      $"/map/{_campaign.activeMap.id}/permissions/reset";
            var request = Server.PostRequest(url, data);

            while (!request.isDone)
            {
                yield return(null);
            }

            Server.GetResponse <Server.Response>(request);

            _gm.RegisterAction(new Action {
                name = GameMaster.ActionNames.RefreshPermissions
            });
        }
        public async Task ResetPin(ResetRequest request)
        {
            await _unitOfWork.Persone.SavePin(request.persona_UId
                                              , EncryptString(request.new_value, AppSettingsConfiguration.masterKey)
                                              , true);

            await _unitOfWork.CompleteAsync();
        }
        public ResetResponse Reset(ResetRequest input)
        {
            debug();

            ResetResponse response = new ResetResponse();

            response.Success = true;

            return(response);
        }
Exemplo n.º 6
0
        public async Task <IHttpActionResult> ResetPassword(ResetRequest request)
        {
            try
            {
                await _logic.ResetPassword(request);

                return(Ok());
            }
            catch (Exception e)
            {
                Log.Error("ResetPassword", e);
                return(ErrorHandler(e));
            }
        }
        public override Task <ResetResponse> RequestReset(ResetRequest request, ServerCallContext context)
        {
            var ret = new ResetResponse();

            try
            {
                _cameraInstance.Features["DeviceReset"].RunCommand();
            }
            catch (Exception e)
            {
                ret.Error = ServiceHelper.BuildError(e, Error.Types.Level.Error);
            }

            return(Task.FromResult(ret));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 对当前机器人的会话状态进行复位
        /// </summary>
        /// <param name="req"><see cref="ResetRequest"/></param>
        /// <returns><see cref="ResetResponse"/></returns>
        public ResetResponse ResetSync(ResetRequest req)
        {
            JsonResponseModel <ResetResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "Reset");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <ResetResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
        public async Task <ActionResult> ResetPassword(ResetRequest request)
        {
            try
            {
                var apiGateway = new ApiGateway(_Token);
                await apiGateway.Admin.ResetPassword(request);

                return(Json("ok", JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(new ErrorResponse(e.Message), JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 10
0
        public async Task <ActionResult> ResetPassword(ResetRequest request)
        {
            try
            {
                await ApiGateway.ResetPassword(request);

                return(Json("ok", JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(new ErrorResponse {
                    message = e.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 11
0
        public void SetNewPassword(ResetRequest request, int userId)
        {
            string salt;
            string passwordHash;

            string cPassword = request.ConfirmPassword;

            salt         = _cryptographyService.GenerateRandomString(RAND_LENGTH);
            passwordHash = _cryptographyService.Hash(cPassword, salt, HASH_ITERATION_COUNT);
            ChangePassword(userId, salt, passwordHash);
            //DB provider call to create user and get us a user id

            //be sure to store both salt and passwordHash
            //DO NOT STORE the original password value that the user passed us

            //void userId = Replace(request, salt, passwordHash);
        }
Exemplo n.º 12
0
        public BaseResponse ResetPasswordRequest(DynamicDictionary _parameters)
        {
            BaseResponse response = new BaseResponse();

            string json = Request.Body.ReadAsString();

            if (json != null)
            {
                ResetRequest rr = JsonConvert.DeserializeObject <ResetRequest>(json);
                if (rr.Email != null &&
                    rr.InstallId != null)
                {
                    HydrantWikiManager manager = new HydrantWikiManager();
                    User user = manager.GetUserByEmail(UserSources.HydrantWiki, rr.Email);
                    if (user != null)
                    {
                        //Send reset password email
                        PasswordReset reset = PasswordReset.GetNewRequest(user.Guid);
                        manager.Persist(reset);

                        NameValueCollection nvc = new NameValueCollection
                        {
                            { "Code", reset.Code }
                        };

                        manager.SendCannedEmail(user, CannedEmailNames.ResetPasswordEmail, nvc);
                        manager.LogInfo(
                            user.Guid,
                            string.Format(
                                "Password Reset Request for user {0} on {1}",
                                user.Username,
                                rr.InstallId));

                        response.Success = true;
                        response.Message = "Password reset email sent.";
                    }
                    else
                    {
                        response.Success = false;
                        response.Message = "";
                    }
                }
            }

            return(response);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Reset the gateway network settings to factory new and/or delete the deCONZ database (config, lights, scenes, groups, schedules, devices, rules).
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <DeConzResults> Reset(ResetRequest request)
        {
            CheckInitialized();

            string command = JsonConvert.SerializeObject(request, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            });

            HttpClient client = await GetHttpClient().ConfigureAwait(false);

            var result = await client.PostAsync(new Uri(string.Format("{0}config/reset", ApiBase)), new JsonContent(command)).ConfigureAwait(false);

            string jsonResult = await result.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(DeserializeDefaultDeConzResult(jsonResult));
        }
        public ResultObj Reset(string email)
        {
            try
            {
                using (var db = new AppDbContext())
                {
                    var existing = db.Users.FirstOrDefault(x => x.UserName == email && !x.Hidden && !x.Locked);
                    if (existing == null)
                    {
                        throw new Exception("Sorry email is not valid. Enjoy!!");
                    }
                    var newRecord = new ResetRequest
                    {
                        Email    = email,
                        Token    = StringHelpers.GenerateRandomString(32),
                        Date     = DateTime.Now,
                        Ip       = Request.Headers.Referrer.AbsoluteUri,
                        IsActive = true
                    };
                    db.ResetRequests.Add(newRecord);

                    // create a password reset entry
                    var link     = Request.Headers.Referrer.AbsoluteUri + "#/resetpassword/" + newRecord.Token;
                    var emailMsg = new EmailOutboxEntry
                    {
                        Message =
                            $"<h3>Password Reset Request</h3> <br/><br/> Please follow the link below to change your password. <br/><br/><b><a href='{link}'>Click here</a></b> to reset your password.<br/><br/><br/><br/>Please ignore this message if you did not make this request.<br/><br/>Thank you. <br/>",
                        Subject  = "Password Reset",
                        Sender   = "*****@*****.**",
                        Receiver = newRecord.Email,
                        Created  = DateTime.Now
                    };
                    db.EmailOutboxEntries.Add(emailMsg);
                    db.SaveChanges();
                    MessageHelpers.SendEmailMessage(emailMsg.Id);

                    return(WebHelpers.BuildResponse(null, "Password reset link has been sent to your email.", true, 1));
                }
            }
            catch (Exception e)
            {
                return(WebHelpers.ProcessException(e));
            }
        }
Exemplo n.º 15
0
        public async Task <IActionResult> ResetPassword([FromBody] ResetRequest request)
        {
            try
            {
                var user = await _userRepository.WithEmail(request.email);

                var password = PasswordGenerator.CreateRandomPassword(8);
                user.Password = _passwordHasher.HashPassword(user, password);
                var cmd    = new ChangePasswordCmd(user.Password, user.Id);
                var result = await _userRepository.ChangePassword(cmd);

                if (result)
                {
                    bool response = MailsHelpers.MailPassword(user.Email, password);
                    if (response)
                    {
                        return(Ok());
                    }
                    else
                    {
                        return(new JsonResult(new ResponseMail("Error al mandar correo", 0, 400))
                        {
                            StatusCode = 400
                        });
                    }
                }
                else
                {
                    return(new JsonResult(new ResponseMail("Error al actualizar", 0, 404))
                    {
                        StatusCode = 404
                    });
                }
            }
            catch (Exception e)
            {
                return(new JsonResult(e.Message)
                {
                    StatusCode = 500
                });
            }
        }
        public static async Task ResetPassword(ResetRequest request)
        {
            try
            {
                var requestUrl = $"{apiUrl}/admin/reset-password";
                var body       = JsonConvert.SerializeObject(request);

                await Put(requestUrl, body);
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.Error("ResetPassword", ex);
                throw ex;
            }
            catch (Exception ex)
            {
                Log.Error("ResetPassword", ex);
                throw ex;
            }
        }
Exemplo n.º 17
0
        public ResetAck OnResetStart(ResetReq msg)
        {
            if (!IsValidEmail(msg.email))
            {
                return(new ResetAck(ResetAck.Result.FAIL_INCORRECT_EMAIL));
            }
            DropExpiredCodes();
            ResetRequest req = GetRequestByEmail(msg.email);

            if (req != null)
            {
                req.createdTime = DateTime.Now;
            }
            else if (!IsUserRegistred(msg))
            {
                return(new ResetAck(ResetAck.Result.FAIL_UNREGISTER_USER));
            }
            else
            {
                req             = new ResetRequest();
                req.createdTime = DateTime.Now;
                req.code        = GenerateCode();
                req.msg         = msg;
                requests.Add(req);
            }
            if (req != null)
            {
                try
                {
                    SendCode(req.msg.email, req.code);
                }
                catch
                {
                    return(new ResetAck(ResetAck.Result.FAIL_INCORRECT_EMAIL));
                }
                return(new ResetAck(ResetAck.Result.SUCCESS));
            }
            return(new ResetAck(ResetAck.Result.UNKNOWN_ERROR));
        }
Exemplo n.º 18
0
        public ConfResetAck OnResetFinish(ConfResetReq msg)
        {
            if (msg.type != 0 && msg.type != 1)
            {
                return(new ConfResetAck(ConfResetAck.Result.FAIL_UNKNOWN_TYPE));
            }
            if (msg.new_pass.Length < 8)
            {
                return(new ConfResetAck(ConfResetAck.Result.FAIL_INCORRECT_PASS));
            }
            DropExpiredCodes();
            ResetRequest request = null;

            foreach (ResetRequest req in requests)
            {
                if (msg.code.Equals(req.code) && msg.type == req.msg.type)
                {
                    request = req;
                    break;
                }
            }
            if (request == null)
            {
                return(new ConfResetAck(ConfResetAck.Result.FAIL_INCORRECT_CODE));
            }
            QueryBase query = null;

            if (msg.type == 0)
            {
                query = new QueryUpdateClientPass(request.msg.email, msg.new_pass, DBUtils.GetDBConnection(), null);
            }
            else
            {
                query = new QueryUpdateSalerPass(request.msg.email, msg.new_pass, DBUtils.GetDBConnection(), null);
            }
            query.Execute();
            requests.Remove(request);
            return(new ConfResetAck(ConfResetAck.Result.SUCCESS));
        }
Exemplo n.º 19
0
        public static async Task <ResetResponse> Reset(bool faceGroups, bool customers, bool orders, bool images)
        {
            var post = new ResetRequest();

            post.FaceGroups = faceGroups;
            post.Customers  = customers;
            post.Orders     = orders;
            post.Images     = images;

            try
            {
                var json        = JsonConvert.SerializeObject(post);
                var httpContent = new StringContent(json, Encoding.UTF8, "application/json");

                return(await MakeRequest <ResetResponse>(ProjectConfig.ResetGroupsUrl, httpContent));
            }
            catch (WebException ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(null);
        }
Exemplo n.º 20
0
        public async Task <int> RequestPasswordReset([FromBody] ResetRequest request)
        {
            try
            {
                if (request == null)
                {
                    throw new ArgumentNullException(nameof(request));
                }
                if (string.IsNullOrEmpty(request.Email))
                {
                    throw new ArgumentNullException(nameof(request), "Email is required");
                }


                var user = (await _userService.SearchUser(request.Email)).FirstOrDefault();

                if (user == null)
                {
                    _logger.LogInformation("Can't find user with email: {email}", request.Email);
                    throw new ArgumentOutOfRangeException(nameof(request), "Invalid Request");
                }

                var token     = Guid.NewGuid().ToString();
                var resetLink = $"https://www.funwithlocal.com/resetpassword/{token}";

                await _emailService.SendResetPasswordEmail(new ResetPasswordEmailViewModel { ResetLink = resetLink }, request.Email);

                var reset = await _userService.RequestPasswordReset(user.Id, token, DateTime.Today.AddDays(2));

                return(reset);
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message, e);
                throw;
            }
        }
Exemplo n.º 21
0
        public async Task ResetPassword(ResetRequest request)
        {
            try
            {
                var persona = await _unitOfWork.Persone.Get(request.persona_UId);

                string ris;
                var    IntranetADService = new proxyAD();
                ris = IntranetADService
                      .ChangeADUserPass(
                    persona.userAD.Replace(@"CONSIGLIO\", ""),
                    string.Empty,
                    request.new_value,
                    AppSettingsConfiguration.TOKEN_W);
                if (!ris.Contains("0:"))
                {
                    throw new Exception("Reset password non riuscito. Motivo: " + ris);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 22
0
        public IActionResult RequestReset(int scorecardId, [FromBody] ResetRequest request)
        {
            _repository.RequestReset(scorecardId, request);

            return(new JsonResult("Success"));
        }
Exemplo n.º 23
0
 public override Task <ResetResponse> ResetBoard(ResetRequest request, ServerCallContext context)
 {
     return(base.ResetBoard(request, context));
 }
Exemplo n.º 24
0
        public async Task <ActionResult> ResetPin(ResetRequest request)
        {
            await ApiGateway.ResetPin(request);

            return(Json("ok", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 25
0
        public async Task ResetPin(ResetRequest request)
        {
            await _unitOfWork.Persone.SavePin(request.persona_UId, request.new_value, false);

            await _unitOfWork.CompleteAsync();
        }