Jelszó módosítása

This commit is contained in:
2025-04-14 12:31:50 +02:00
parent 44e6719c3d
commit 29200ae418
18 changed files with 676 additions and 9 deletions
@@ -0,0 +1,43 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WorkFlowCheck.BL.Services.Interfaces;
using WorkFlowCheck.Common.DTO;
namespace WorkFlowCheck.API.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class SystemController : ControllerBase
{
private readonly ISystemService _systemService;
public SystemController(ISystemService systemService)
{
_systemService = systemService;
}
[HttpGet("GetDatabaseAndVersionInfo")]
public async Task<ApiResponseDTO<string>> GetDatabaseAndVersionInfo()
{
var retVal = new ApiResponseDTO<string>()
{
IsSuccess = true,
};
var result = await _systemService.GetDatabaseAndVersionInfoAsync();
if (result != null)
{
retVal.IsSuccess = true;
retVal.Data = result;
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
return retVal;
}
}
}
@@ -257,6 +257,62 @@ namespace WorkFlowCheck.API.Controllers
}
return retVal;
}
[HttpPost("Authenticate2F2ChangePassword")]
public async Task<ApiResponseDTO<UserDTO>> Authenticate2F2ChangePassword([FromBody] UserChangePassword2FADTO userChangePassword2FADTO)
{
var retVal = new ApiResponseDTO<UserDTO>()
{
IsSuccess = true
};
if (string.IsNullOrEmpty(userChangePassword2FADTO.UserName) ||
string.IsNullOrEmpty(userChangePassword2FADTO.OldPassword) ||
string.IsNullOrEmpty(userChangePassword2FADTO.NewPassword1) ||
string.IsNullOrEmpty(userChangePassword2FADTO.NewPassword2) ||
string.IsNullOrEmpty(userChangePassword2FADTO.Code) ||
string.IsNullOrEmpty(userChangePassword2FADTO.Token2FA))
{
retVal.IsSuccess = false;
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
return retVal;
}
try
{
var userDTO_Response = await _userService.Authenticate2F2ChangePassword(userChangePassword2FADTO.UserName,
userChangePassword2FADTO.OldPassword,
userChangePassword2FADTO.NewPassword1,
userChangePassword2FADTO.Code,
userChangePassword2FADTO.Token2FA);
if (userDTO_Response != null)
{
if (string.IsNullOrEmpty(userDTO_Response.UserName) == false)
{
retVal.IsSuccess = true;
retVal.Data = userDTO_Response;
Log.Information($"Sikeres azonosítás! {userChangePassword2FADTO.UserName}");
}
else
{
var error = $"Nem megfelelo felhasználó vagy jelszó! {userChangePassword2FADTO.UserName}";
retVal.IsSuccess = false;
retVal.Errors.Add(error);
Log.Information(error);
}
}
else
{
var error = $"Nem megfelelo felhasználó vagy jelszó! {userChangePassword2FADTO.UserName}";
retVal.IsSuccess = false;
retVal.Errors.Add(error);
Log.Information(error);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
[HttpPost("AuthenticateNFC")]
public async Task<ApiResponseDTO<UserDTO>> AuthenticateNFC([FromBody] UserSimpleDTO userSimpleDTO)
{
@@ -695,5 +751,6 @@ namespace WorkFlowCheck.API.Controllers
}
return retVal;
}
}
}
@@ -1,4 +1,7 @@
{
"ConnectionStrings": {
"DefaultConnection": "Data Source=WS2016DC\\SQLEXPRESS;Initial Catalog=WFC;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False"
},
"Logging": {
"LogLevel": {
"Default": "Information",
+1
View File
@@ -18,6 +18,7 @@ namespace WorkFlowCheck.BL.Infra
service.AddScoped<ICheckListService, CheckListService>();
service.AddScoped<INumberGeneratorService, NumberGeneratorService>();
service.AddScoped<IMessageService, MessageService>();
service.AddScoped<ISystemService, SystemService>();
}
}
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkFlowCheck.BL.Services.Interfaces
{
public interface ISystemService
{
Task<string> GetDatabaseAndVersionInfoAsync();
}
}
@@ -16,6 +16,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces
Task<UserDTO> Authenticate(string UserName, string Password);
Task<string> Authenticate2F1(string UserName, string Password);
Task<UserDTO> Authenticate2F2(string UserName, string Password, string Code, string token2FA);
Task<UserDTO> Authenticate2F2ChangePassword(string UserName, string OldPassword, string NewPassword, string Code, string token2FA);
Task<UserDTO> AuthenticateNFC(string NFCCode);
@@ -0,0 +1,49 @@
using AutoMapper;
using DocumentFormat.OpenXml.InkML;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorkFlowCheck.BL.Services.Interfaces;
using WorkFlowCheck.DL;
namespace WorkFlowCheck.BL.Services
{
public class SystemService : ISystemService
{
public readonly AppDbContext _dbContext;
public readonly IMapper _mapper;
public readonly IConfiguration _config;
public SystemService(AppDbContext dbContext,
IMapper mapper,
IConfiguration configuration)
{
_config = configuration;
_dbContext = dbContext;
_mapper = mapper;
}
public async Task<string> GetDatabaseAndVersionInfoAsync()
{
var retVal = "";
var connection = _dbContext.Database.GetDbConnection();
var typeName = connection.GetType().Name;
//if (typeName.Contains("Npgsql"))
//{
// var builder = new NpgsqlConnectionStringBuilder(connection.ConnectionString);
// retVal= builder.Database;
//}
if (typeName.Contains("SqlConnection"))
{
var builder = new SqlConnectionStringBuilder(connection.ConnectionString);
retVal= builder.InitialCatalog;
}
return retVal;
}
}
}
@@ -209,6 +209,53 @@ namespace WorkFlowCheck.BL.Services
return retVal;
}
public async Task<UserDTO> Authenticate2F2ChangePassword(string userName, string oldPassword, string newPassword, string code, string token2FA)
{
var retVal = new UserDTO() { RoleDTO = new List<RoleDTO>() };
try
{
var user = await _dbContext.Users
.Include(i => i.UserRoles)
.ThenInclude(i => i.Role)
.Where(w => w.UserName == userName && w.Active != false)
.FirstOrDefaultAsync();
if (user != null && PasswordHasher.VerifyPassword(user.PasswordHash, oldPassword))
{
if (CodeGenerator2F.ValidateToken2F(token2FA, userName, oldPassword, code))
{
user.PasswordHash = PasswordHasher.HashPassword(newPassword);
var userDTO = new UserDTO()
{
Id = user.Id,
UserName = user.UserName,
RoleDTO = new List<RoleDTO>(),
};
foreach (var item in user.UserRoles)
{
userDTO.RoleDTO.Add(new RoleDTO()
{
Id = item.Role.Id,
RoleName = item.Role.RoleName,
});
}
user.PasswordHash = PasswordHasher.HashPassword(newPassword);
user.JwtToken = GenerateJwtToken(userDTO);
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<UserDTO>(user);
return retVal;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<UserDTO> AuthenticateNFC(string NFCCode)
{
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkFlowCheck.Common.DTO
{
public class UserChangePassword2FADTO
{
public int UserId { get; set; }
[DisplayName("Felhasználó")]
public string UserName { get; set; } = null!;
[DisplayName("Régi jelszó")]
public string OldPassword { get; set; } = null!;
[DisplayName("Új jelszó")]
public string NewPassword1 { get; set; } = null!;
[DisplayName("Jelszó megerősítése")]
public string NewPassword2 { get; set; } = null!;
[DisplayName("Ellenőrző kód")]
public string Code { get; set; } = null!;
public string Token2FA { get; set; } = null!;
}
}
@@ -0,0 +1,42 @@
using Serilog;
using System.Net.Http;
using WorkFlowCheck.Common.DTO;
namespace WorkFlowCheck.Web.Helpers
{
public static class SystemHelper
{
public static string DatabaseName = "";
public async static Task GetAPIInfoAsync(IConfiguration configuration)
{
using (var httpClient = new HttpClient())
{
var apiBaseUrl = configuration["ApiBaseUrl"]; // API-cím elérése a konfigurációból
httpClient.BaseAddress = new Uri(apiBaseUrl);
var apiKey = configuration["ApiKey"];
httpClient.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
string endpoint = $"{httpClient.BaseAddress}api/System/GetDatabaseAndVersionInfo";
var retVal = new RoleDTO();
try
{
var response = await httpClient.GetFromJsonAsync<ApiResponseDTO<string>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
DatabaseName = response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
}
}
}
}
@@ -0,0 +1,212 @@
@page "{userId:int?}"
@model WorkFlowCheck.Web.Pages.Account.ChangePasswordModel
@using WorkFlowCheck.Common.Helper
@using WorkFlowCheck.Common.DTO
@using Microsoft.AspNetCore.Antiforgery
@inject IAntiforgery Antiforgery
@{
Layout = null;
ViewData["Title"] = "Jelszó módosítása";
}
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>@ViewData["Title"]</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light d-flex justify-content-center align-items-center vh-100">
<div class="card shadow p-4" style="min-width: 350px; max-width: 400px; width: 100%;">
<h2 class="mb-4 text-center">Jelszó módosítása</h2>
<div id="errorMessageContainer" class="alert alert-danger" style="display:none;"></div>
<form method="post">
<meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" />
<input type="hidden" asp-for="UserChangePassword2FADTO.UserId" />
<input type="hidden" asp-for="UserChangePassword2FADTO.Token2FA" />
<div class="mb-3">
<label asp-for="UserChangePassword2FADTO.UserName" class="form-label"></label>
<input asp-for="UserChangePassword2FADTO.UserName" class="form-control" disabled />
<span asp-validation-for="UserChangePassword2FADTO.UserName" class="text-danger small"></span>
</div>
<div class="mb-3">
<label asp-for="UserChangePassword2FADTO.OldPassword" class="form-label"></label>
<input asp-for="UserChangePassword2FADTO.OldPassword" type="password" class="form-control" />
<span asp-validation-for="UserChangePassword2FADTO.OldPassword" class="text-danger small"></span>
</div>
<div class="mb-3">
<label asp-for="UserChangePassword2FADTO.NewPassword1" class="form-label"></label>
<input asp-for="UserChangePassword2FADTO.NewPassword1" type="password" class="form-control" />
<span asp-validation-for="UserChangePassword2FADTO.NewPassword1" class="text-danger small"></span>
</div>
<div class="mb-3">
<label asp-for="UserChangePassword2FADTO.NewPassword2" class="form-label"></label>
<input asp-for="UserChangePassword2FADTO.NewPassword2" type="password" class="form-control" />
<span asp-validation-for="UserChangePassword2FADTO.NewPassword2" class="text-danger small"></span>
</div>
<div id="VerificationCode" class="mb-3">
<label asp-for="UserChangePassword2FADTO.Code" class="form-label"></label>
<input asp-for="UserChangePassword2FADTO.Code" class="form-control" />
<span asp-validation-for="UserChangePassword2FADTO.Code" class="text-danger small"></span>
</div>
<hr class="mt-4 mb-3 border-secondary">
<div id="login2F1" class="d-grid">
<button id="Login2F1Btn" type="button" class="btn btn-primary">Bejelentkezés</button>
</div>
<div id="login2F2" class="d-grid">
<button id="Login2F2Btn" type="button" class="btn btn-primary">Megerősítés</button>
</div>
</form>
</div>
<!-- Message Modal -->
<div class="modal fade" id="messageModal" tabindex="-1" aria-labelledby="messageModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="messageModalLabel">Üzenet</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Bezárás"></button>
</div>
<div class="modal-body" id="messageModalBody">
Ez egy információs üzenet.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="messageModalOkBtn" data-bs-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<script src="~/js/site.js" asp-append-version="true"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation-unobtrusive@4.0.0/dist/jquery.validate.unobtrusive.min.js"></script>
<script>
$(document).ready(function () {
$('#VerificationCode').hide();
$('#login2F2').hide();
$('#Login2F2Btn').hide();
$('#UserChangePassword2FADTO_UserName').attr('readonly', true);
$('#Login2F1Btn').on('click', function () {
// $('#Login2F1Btn, #Login2F2Btn').prop('disabled', true);
$('#errorMessageContainer').hide().text('');
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
const userName = $('#UserChangePassword2FADTO_UserName').val();
const password = $('#UserChangePassword2FADTO_OldPassword').val();
$.ajax({
url: '/Account/ChangePassword?handler=Login2F1',
type: 'POST',
headers: {
'X-CSRF-TOKEN': csrfToken,
'Content-Type': 'application/json'
},
contentType: 'application/json',
data: JSON.stringify({
UserName: userName,
Password: password
}),
success: function (result) {
if (result.success) {
$('#login2F1').hide();
$('#Login2F1Btn').hide();
$('#VerificationCode').show();
$('#login2F2').show();
$('#Login2F2Btn').show();
$('#UserChangePassword2FADTO_Token2FA').val(result.data)
} else {
$('#errorMessageContainer').text('Hibás felhasználónév vagy jelszó!').show();
// $('#Login2F1Btn, #Login2F2Btn')
// .prop('disabled', false)
// .removeAttr('disabled')
// .removeClass('disabled');
}
},
error: function () {
$('#errorMessageContainer').text('Hiba történt a kérés során.').show();
// $('#Login2F1Btn, #Login2F2Btn')
// .prop('disabled', false)
// .removeAttr('disabled')
// .removeClass('disabled');
}
});
});
$('#Login2F2Btn').on('click', function () {
// $('#Login2F1Btn, #Login2F2Btn').prop('disabled', true);
$('#errorMessageContainer').hide().text('');
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
const userName = $('#UserChangePassword2FADTO_UserName').val();
const password = $('#UserChangePassword2FADTO_OldPassword').val();
const newpassword1 = $('#UserChangePassword2FADTO_NewPassword1').val();
const newpassword2 = $('#UserChangePassword2FADTO_NewPassword2').val();
const code = $('#UserChangePassword2FADTO_Code').val();
const token2FA = $('#UserChangePassword2FADTO_Token2FA').val();
$.ajax({
url: '/Account/ChangePassword?handler=Login2F2',
type: 'POST',
headers: {
'X-CSRF-TOKEN': csrfToken,
'Content-Type': 'application/json'
},
contentType: 'application/json',
data: JSON.stringify({
UserId: 0,
UserName: userName,
OldPassword: password,
NewPassword1: newpassword1,
NewPassword2: newpassword2,
Code: code,
Token2FA: token2FA
}),
success: function (result) {
if (result.success) {
showMessageModal({
title: 'Információ',
message: 'A jelszó módosítása sikerült!',
okText: 'Értettem',
redirectUrl: '/Index'
});
} else {
$('#errorMessageContainer').text('Hibás felhasználónév vagy jelszó!').show();
// $('#Login2F1Btn, #Login2F2Btn')
// .prop('disabled', false)
// .removeAttr('disabled')
// .removeClass('disabled');
}
},
error: function (xhr) {
console.log(xhr.status);
console.log(xhr.responseText);
$('#errorMessageContainer').text('Hiba történt a kérés során.').show();
// $('#Login2F1Btn, #Login2F2Btn')
// .prop('disabled', false)
// .removeAttr('disabled')
// .removeClass('disabled');
}
});
});
$('input').on('input', function () {
$('#errorMessageContainer').hide().text('');
});
});
</script>
<partial name="_ValidationScriptsPartial" />
</body>
</html>
@@ -0,0 +1,98 @@
using FluentValidation;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Net.NetworkInformation;
using System.Security.Claims;
using System.Text.Json;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services.Interfaces;
namespace WorkFlowCheck.Web.Pages.Account
{
[Authorize]
[ValidateAntiForgeryToken]
public class ChangePasswordModel : PageModel
{
private readonly IUserService _userService;
[BindProperty]
public UserChangePassword2FADTO UserChangePassword2FADTO { get; set; }
public string ErrorMessage { get; set; }
public ChangePasswordModel(IUserService userService)
{
_userService = userService;
}
public async Task OnGet()
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var user = await _userService.GetUser(int.Parse(userId));
if (user != null && user.Id > 0)
{
UserChangePassword2FADTO = new UserChangePassword2FADTO()
{
UserName = user.UserName,
UserId = user.Id,
};
}
}
public async Task<IActionResult> OnPostLogin2F1([FromBody] UserSimpleDTO userSimpleDTO)
{
if (userSimpleDTO != null)
{
var response = await _userService.Authenticate2F1(userSimpleDTO.UserName, userSimpleDTO.Password);
if (response.IsSuccess)
{
return new JsonResult(new { success = true, data = response.Data });
}
else
{
ErrorMessage = "Hibás bejelentkezés!";
return new JsonResult(new { success = false });
}
}
else
{
ErrorMessage = "Hibás bejelentkezés!";
return new JsonResult(new { success = false });
}
}
public async Task<IActionResult> OnPostLogin2F2([FromBody] UserChangePassword2FADTO userChangePassword2FADTO)
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var user = await _userService.GetUser(int.Parse(userId));
userChangePassword2FADTO.UserId = user.Id;
var response = await _userService.Authenticate2F2ChangePassword(userChangePassword2FADTO.UserName,
userChangePassword2FADTO.OldPassword,
userChangePassword2FADTO.NewPassword1,
userChangePassword2FADTO.Code,
userChangePassword2FADTO.Token2FA);
if (response.IsSuccess)
{
var token = response.Data.JwtToken;
Response.Cookies.Append("AuthToken", token, new CookieOptions
{
HttpOnly = true,
Secure = true,
SameSite = SameSiteMode.Strict,
Expires = DateTimeOffset.UtcNow.AddMinutes(30)
});
return new JsonResult(new { success = true });
}
ErrorMessage = "Hibás bejelentkezés!";
return new JsonResult(new { success = false });
}
}
}
@@ -1,4 +1,6 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="utf-8" />
@@ -64,11 +66,24 @@
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link text-dark" href="#" data-bs-toggle="modal" data-bs-target="#logoutModal">
<i class="bi bi-box-arrow-right"></i>Logout (@User.Identity.Name)
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle text-dark" href="#" id="accountDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Adataim
</a>
<ul class="dropdown-menu" aria-labelledby="accountDropdown">
<li class="dropdown-item">
<a class="nav-link text-dark" href="#" data-bs-toggle="modal" data-bs-target="#logoutModal">
<i class="bi bi-box-arrow-right"></i>Logout (@User.Identity.Name)
</a>
</li>
<li>
<a class="dropdown-item" asp-area="" asp-page="/Account/ChangePassword">
Jelszó módosítása
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
@@ -138,7 +153,7 @@
<footer class="border-top footer text-muted">
<div class="container">
&copy; @DateTime.Now.Year - Workflow Check App - Version v1.1.003 <a asp-area="" asp-page="/Privacy">Privacy</a>
&copy; @DateTime.Now.Year - Workflow Check App - Version v1.1.003 (@SystemHelper.DatabaseName)<a asp-area="" asp-page="/Privacy">Privacy</a>
</div>
</footer>
@@ -1,3 +1,4 @@
@using WorkFlowCheck.Web
@using WorkFlowCheck.Web.Helpers
@namespace WorkFlowCheck.Web.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
+6
View File
@@ -5,6 +5,7 @@ using Microsoft.IdentityModel.Tokens;
using Serilog;
using System.Text;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Helpers;
using WorkFlowCheck.Web.Middleware;
using WorkFlowCheck.Web.Services;
using WorkFlowCheck.Web.Services.Interfaces;
@@ -61,6 +62,11 @@ builder.WebHost.ConfigureKestrel(options =>
var app = builder.Build();
using (var scope = app.Services.CreateScope())
{
var config = scope.ServiceProvider.GetRequiredService<IConfiguration>();
await SystemHelper.GetAPIInfoAsync(config);
}
//----------------- Munkakönyvtárak létrehozása -----------------------------
string imageDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Images");
@@ -9,7 +9,8 @@ namespace WorkFlowCheck.Web.Services.Interfaces
Task<ApiResponseDTO<UserDTO>> UpdateUser(UserDTO userDTO);
Task<ApiResponseDTO<UserDTO>> Authenticate(string username, string password);
Task<ApiResponseDTO<string>> Authenticate2F1(string username, string password);
Task<ApiResponseDTO<UserDTO>> Authenticate2F2(string userName, string password, string code, string token2FA);
Task<ApiResponseDTO<UserDTO>> Authenticate2F2(string username, string password, string code, string token2FA);
Task<ApiResponseDTO<UserDTO>> Authenticate2F2ChangePassword(string username, string oldpassword,string newpassword, string code, string token2FA);
Task<bool> DeleteUser(int id);
Task<RoleDTO> GetRole(int id);
@@ -195,6 +195,48 @@ namespace WorkFlowCheck.Web.Services
};
}
}
public async Task<ApiResponseDTO<UserDTO>> Authenticate2F2ChangePassword(string username, string oldpassword, string newpassword, string code, string token2FA)
{
try
{
string endpoint = $"{_httpClient.BaseAddress}api/User/Authenticate2F2ChangePassword";
var userSimpleDTO = new UserChangePassword2FADTO()
{
UserName = username,
OldPassword = oldpassword,
NewPassword1 = newpassword,
NewPassword2 = newpassword,
Code = code,
Token2FA = token2FA
};
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, userSimpleDTO))
{
httpResponseMessage.EnsureSuccessStatusCode();
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
var response = JsonConvert.DeserializeObject<ApiResponseDTO<UserDTO>>(jsonString);
return response ?? new ApiResponseDTO<UserDTO>
{
IsSuccess = false,
};
}
}
catch (Exception ex)
{
return new ApiResponseDTO<UserDTO>
{
IsSuccess = false
};
}
}
public async Task<bool> DeleteUser(int id)
{
string endpoint = $"{_httpClient.BaseAddress}api/User/DeleteUser/{id}";
+8 -1
View File
@@ -77,7 +77,8 @@ function showMessageModal(options) {
var defaults = {
title: 'Üzenet',
message: 'Ez egy információs üzenet.',
okText: 'OK'
okText: 'OK',
redirectUrl: null
};
var settings = $.extend({}, defaults, options);
@@ -87,6 +88,12 @@ function showMessageModal(options) {
$('#messageModalBody').html(settings.message);
$('#messageModalOkBtn').text(settings.okText);
$('#messageModalOkBtn').off('click').on('click', function () {
if (settings.redirectUrl) {
window.location.href = settings.redirectUrl;
}
});
// Modal megnyitása
var modal = new bootstrap.Modal(document.getElementById('messageModal'), {
backdrop: 'static',