示例#1
0
        public async Task <IActionResult> ChangePassword(string code, string email, string password)
        {
            string cltMsgText = "";

            email = email.ToLower();

            //string k = SecurCare.ReadRSAKey().x;
            //string dpassword = openSSL_RSA.DecryptByPrivKey(password, k);

            if (sc.validateEmail(email) || sc.validatePassword(password))
            {
                // HttpContext.Response.StatusCode = StatusCodes.Status400BadRequest;
                return(BadRequest());
            }

            if (!ValidateCode(code))
            {
                return(new ObjectResult(new { token = "", msg = "Code is not valid." }));
            }


            User user = await _dbRepo.GetItem <User>(email);

            if (user == null)
            {
                cltMsgText = $"User with email: {email} is not exists!";
                return(new ObjectResult(new { token = "", msg = cltMsgText }));
            }

            user.Password = _passwordHasher.GenerateIdentityV3Hash(password);
            await _dbRepo.UpdateItem(user, true);

            var atoken = GenerateJSONWebToken(user);

            return(new ObjectResult(new { token = atoken, msg = "" }));
        }
示例#2
0
 public IEnumerable <Celebrity> UpdateCelebrity(string name, Celebrity updatedItem)
 {
     dbRepo.UpdateItem(nameof(Celebrity.Name), name, updatedItem);
     return(GetData().Result);
 }