예제 #1
0
        public async Task <string> ForcePasswordChange([FromBody] JObject data)
        {
            try
            {
                if (data != null)
                {
                    StringConversion stringConversion = new StringConversion();
                    string           userId           = stringConversion.DecryptString(data["userId"].ToString()); //Decrypting the userId sent from the View

                    string password = data["password"].ToString();
                    var    response = await _bosAuthClient.ForcePasswordChangeAsync(Guid.Parse(userId), password); //Making an call to the BOS API to ForceChange the Password. This is done because at this point there is no way of knowing the user's original password

                    if (response != null && response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                    {
                        return("Token Expired, Please login again");
                    }
                    if (response != null && response.IsSuccessStatusCode)
                    {
                        return("Password updated successfully"); //On success, returing a message
                    }
                    else
                    {
                        Logger.LogException("Auth", "ForcePasswordChange", null);
                        return("Something went wrong. We are not able to change the password at this moment. Please try again later.");
                    }
                }
                else
                {
                    return("Data cannot be null");
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("Auth", "ForcePasswordChange", ex);
                return("Something went wrong. We are not able to change the password at this moment. Please try again later.");
            }
        }