|
|
@ -30,6 +30,7 @@ using System.IO; |
|
|
|
using Abp.AutoMapper; |
|
|
|
using Abp.Domain.Entities; |
|
|
|
using BCS.BMC.BMC.FirebaseCloudMessages; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
|
|
|
|
namespace BCS.BMC.Controllers |
|
|
|
{ |
|
|
@ -430,5 +431,198 @@ namespace BCS.BMC.Controllers |
|
|
|
} |
|
|
|
return Ok("Success"); |
|
|
|
} |
|
|
|
|
|
|
|
//[HttpPost]
|
|
|
|
//public async Task<IActionResult> ForgotPasswordForBmcUser([FromBody] ForgotPasswordInput input)
|
|
|
|
//{
|
|
|
|
// using (HttpClient client = new HttpClient())
|
|
|
|
// {
|
|
|
|
// var baseUrl = input.CompanyUrl + "/api/services/bwac/employeeRegister/RegisterEmployeeAsNewUser";
|
|
|
|
|
|
|
|
// var data = new
|
|
|
|
// {
|
|
|
|
// userName = input.UserName,
|
|
|
|
// AppType = input.AppType
|
|
|
|
// };
|
|
|
|
// var requestJson = JsonConvert.SerializeObject(data);
|
|
|
|
// var requestContent = new StringContent(requestJson.ToString());
|
|
|
|
// requestContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
|
|
|
|
// HttpResponseMessage response = await client.PostAsync(baseUrl, requestContent);
|
|
|
|
// return Ok("Success");
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//----------------------
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
public async Task<IActionResult> GetBmcPhoneOrEmailByUserId([FromBody] ForgotPasswordInput input) |
|
|
|
{ |
|
|
|
Uri uri = new Uri(input.CompanyUrl, UriKind.Absolute); |
|
|
|
var domain = uri.Host; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.CompanyUrl)) |
|
|
|
{ |
|
|
|
return BadRequest("Please Enter A Valid Url"); |
|
|
|
} |
|
|
|
var company = await _companyMaster.FirstOrDefaultAsync(x => x.DomainName == domain); |
|
|
|
if (company == null) |
|
|
|
{ |
|
|
|
return BadRequest("Url Not Found"); |
|
|
|
} |
|
|
|
|
|
|
|
using (HttpClient client = new HttpClient()) |
|
|
|
{ |
|
|
|
var baseUrl = input.CompanyUrl + "api/services/bwac/bmcUserForgotPassword/GetPhoneOrEmailByUserId"; |
|
|
|
|
|
|
|
var data = new |
|
|
|
{ |
|
|
|
userName = input.UserName, |
|
|
|
appType = input.AppType |
|
|
|
}; |
|
|
|
var requestJson = JsonConvert.SerializeObject(data); |
|
|
|
var requestContent = new StringContent(requestJson.ToString()); |
|
|
|
requestContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json"); |
|
|
|
HttpResponseMessage response = await client.PostAsync(baseUrl, requestContent); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
|
var contents = await response.Content.ReadAsStringAsync(); |
|
|
|
ForgotPasswordUserResponse result = JsonConvert.DeserializeObject<ForgotPasswordUserResponse>(contents); |
|
|
|
var emailOrPhone = result.result; |
|
|
|
int num; |
|
|
|
bool isMobile = Int32.TryParse(emailOrPhone,out num); |
|
|
|
if (isMobile) |
|
|
|
{ |
|
|
|
result.type = "phoneNo"; |
|
|
|
return Ok(result); |
|
|
|
} |
|
|
|
if (!isMobile) |
|
|
|
{ |
|
|
|
result.type = "emailAddress"; |
|
|
|
return Ok(result); |
|
|
|
} |
|
|
|
} |
|
|
|
var content = await response.Content.ReadAsStringAsync(); |
|
|
|
ResponseMessageModel results = JsonConvert.DeserializeObject<ResponseMessageModel>(content); |
|
|
|
return BadRequest(results.error.message.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
[HttpPost] |
|
|
|
public async Task<IActionResult> ForgotPasswordForBmcUser([FromBody] ForgotPasswordInput input) |
|
|
|
{ |
|
|
|
Uri uri = new Uri(input.CompanyUrl, UriKind.Absolute); |
|
|
|
var domain = uri.Host; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.CompanyUrl)) |
|
|
|
{ |
|
|
|
return BadRequest("Please Enter A Valid Url"); |
|
|
|
} |
|
|
|
var company = await _companyMaster.FirstOrDefaultAsync(x => x.DomainName == domain); |
|
|
|
if (company == null) |
|
|
|
{ |
|
|
|
return BadRequest("Url Not Found"); |
|
|
|
} |
|
|
|
|
|
|
|
using (HttpClient client = new HttpClient()) |
|
|
|
{ |
|
|
|
var baseUrl = input.CompanyUrl + "api/services/bwac/bmcUserForgotPassword/ForgotPassword"; |
|
|
|
|
|
|
|
var data = new |
|
|
|
{ |
|
|
|
userName = input.UserName, |
|
|
|
appType = input.AppType |
|
|
|
}; |
|
|
|
var requestJson = JsonConvert.SerializeObject(data); |
|
|
|
var requestContent = new StringContent(requestJson.ToString()); |
|
|
|
requestContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json"); |
|
|
|
HttpResponseMessage response = await client.PostAsync(baseUrl, requestContent); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
|
return Ok(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var contents = await response.Content.ReadAsStringAsync(); |
|
|
|
ResponseMessageModel result = JsonConvert.DeserializeObject<ResponseMessageModel>(contents); |
|
|
|
return BadRequest(result.error.message.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
public async Task<IActionResult> BmcAuthenticateForgotPasswordCode([FromBody] ForgotPasswordUserAndCodeInput input) |
|
|
|
{ |
|
|
|
Uri uri = new Uri(input.CompanyUrl, UriKind.Absolute); |
|
|
|
var domain = uri.Host; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.CompanyUrl)) |
|
|
|
{ |
|
|
|
return BadRequest("Please Enter A Valid Url"); |
|
|
|
} |
|
|
|
var company = await _companyMaster.FirstOrDefaultAsync(x => x.DomainName == domain); |
|
|
|
if (company == null) |
|
|
|
{ |
|
|
|
return BadRequest("Url Not Found"); |
|
|
|
} |
|
|
|
|
|
|
|
using (HttpClient client = new HttpClient()) |
|
|
|
{ |
|
|
|
var baseUrl = input.CompanyUrl + "api/services/bwac/bmcUserForgotPassword/BmcAuthenticateForgotPasswordCode"; |
|
|
|
|
|
|
|
var data = new |
|
|
|
{ |
|
|
|
userName = input.UserName, |
|
|
|
code = input.Code |
|
|
|
}; |
|
|
|
var requestJson = JsonConvert.SerializeObject(data); |
|
|
|
var requestContent = new StringContent(requestJson.ToString()); |
|
|
|
requestContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json"); |
|
|
|
HttpResponseMessage response = await client.PostAsync(baseUrl, requestContent); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
|
return Ok(); |
|
|
|
} |
|
|
|
var contents = await response.Content.ReadAsStringAsync(); |
|
|
|
ResponseMessageModel result = JsonConvert.DeserializeObject<ResponseMessageModel>(contents); |
|
|
|
return BadRequest(result.error.message.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
public async Task<IActionResult> BmcResetPassword([FromBody] ForgotPasswordUserAndPwdInput input) |
|
|
|
{ |
|
|
|
Uri uri = new Uri(input.CompanyUrl, UriKind.Absolute); |
|
|
|
var domain = uri.Host; |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.CompanyUrl)) |
|
|
|
{ |
|
|
|
return BadRequest("Please Enter A Valid Url"); |
|
|
|
} |
|
|
|
var company = await _companyMaster.FirstOrDefaultAsync(x => x.DomainName == domain); |
|
|
|
if (company == null) |
|
|
|
{ |
|
|
|
return BadRequest("Url Not Found"); |
|
|
|
} |
|
|
|
|
|
|
|
using (HttpClient client = new HttpClient()) |
|
|
|
{ |
|
|
|
var baseUrl = input.CompanyUrl + "api/services/bwac/bmcUserForgotPassword/BmcResetPassword"; |
|
|
|
|
|
|
|
var data = new |
|
|
|
{ |
|
|
|
userName = input.UserName, |
|
|
|
password = input.Password |
|
|
|
}; |
|
|
|
var requestJson = JsonConvert.SerializeObject(data); |
|
|
|
var requestContent = new StringContent(requestJson.ToString()); |
|
|
|
requestContent.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json"); |
|
|
|
HttpResponseMessage response = await client.PostAsync(baseUrl, requestContent); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
|
return Ok(); |
|
|
|
} |
|
|
|
var contents = await response.Content.ReadAsStringAsync(); |
|
|
|
ResponseMessageModel result = JsonConvert.DeserializeObject<ResponseMessageModel>(contents); |
|
|
|
return BadRequest(result.error.message.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |