#190 delete account is now works in UI
This commit is contained in:
parent
cb9c09340a
commit
d85ef959ca
@ -8,6 +8,9 @@
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
|
||||
@if (Model.Step1)
|
||||
{
|
||||
<form method="post" asp-page-handler="SendEmail">
|
||||
<table style="width:100%" class="noborder">
|
||||
<tr>
|
||||
@ -25,10 +28,10 @@
|
||||
<span class="inputlabel">گذرواژه: </span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" style="width:100%" asp-for="DeleteViewModel.Password" />
|
||||
<input type="password" style="width:100%;direction:ltr" asp-for="DeleteViewModel.Password" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<button type="submit" name="approve" id="approve" style="width:100%;color:white;background-color:green">بررسی گذرواژه و ارسال ایمیل تأیید</button>
|
||||
@ -47,5 +50,36 @@
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<div><p style="color:red">@Model.FatalError</p></div>
|
||||
</form>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form method="post" asp-page-handler="FinalizeDelete">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<p>لطفا پست الکترونیکی خود را بررسی کنید. در صورتی که نشانی پست الکترونیکی خود را درست وارد کرده باشید نامهای از گنجور دریافت کردهاید که حاوی یک رمز است. </p>
|
||||
<p>رمز دریافتی را در کادر زیر وارد کرده، روی دکمهٔ «ادامه» کلیک کنید</p>
|
||||
<p style="color:red">تذکر: ممکن است نامه به پوشه اسپم منتقل شده باشد</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span class="inputlabel">رمز دریافتی:</span>
|
||||
</td>
|
||||
<td>
|
||||
<input asp-for="Secret" placeholder="رمز دریافتی" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a role="button" style="cursor: pointer; width: 100%; color: white; background-color: red; display: block" href="/resetpassword">برگشت</a></td>
|
||||
<td><input type="submit" name="submit" id="submit" value="ادامه" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div><p style="color:red">@Model.FatalError</p></div>
|
||||
</form>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,19 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using RSecurityBackend.Models.Auth.ViewModels;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GanjooRazor.Areas.User.Pages
|
||||
{
|
||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
||||
public class DeleteAccountModel : PageModel
|
||||
{
|
||||
/// <summary>
|
||||
/// fatal error
|
||||
/// </summary>
|
||||
public string FatalError { get; set; }
|
||||
|
||||
public bool Step1 { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public SelfDeleteViewModel DeleteViewModel { get; set; }
|
||||
public void OnGet()
|
||||
|
||||
[BindProperty]
|
||||
public string Secret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// configuration
|
||||
/// </summary>
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public DeleteAccountModel(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
FatalError = "";
|
||||
if (!string.IsNullOrEmpty(Request.Query["secret"]))
|
||||
return await OnPostFinalizeDeleteAsync(Request.Query["secret"]);
|
||||
|
||||
Step1 = true;
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSendEmailAsync(SelfDeleteViewModel deleteViewModel)
|
||||
{
|
||||
Step1 = true;
|
||||
FatalError = "";
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
deleteViewModel.CallbackUrl = $"{_configuration["SiteUrl"]}/User/DeleteAccount";
|
||||
HttpResponseMessage response = await secureClient.PostAsync(
|
||||
$"{APIRoot.Url}/api/users/selfdelete/start",
|
||||
new StringContent(JsonConvert.SerializeObject(deleteViewModel),
|
||||
Encoding.UTF8,
|
||||
"application/json"
|
||||
));
|
||||
if(!response.IsSuccessStatusCode)
|
||||
{
|
||||
FatalError = await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
Step1 = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<IActionResult> OnPostFinalizeDeleteAsync(string Secret)
|
||||
{
|
||||
FatalError = "";
|
||||
Step1 = false;
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
HttpResponseMessage response = await secureClient.DeleteAsync(
|
||||
$"{APIRoot.Url}/api/users/selfdelete/finalize/{Secret}"
|
||||
);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
FatalError = await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var cookieOption = new CookieOptions()
|
||||
{
|
||||
Expires = DateTime.Now.AddDays(-1)
|
||||
};
|
||||
foreach (var cookieName in new string[] { "UserId", "SessionId", "Token", "Username", "Name", "NickName", "CanEdit" })
|
||||
{
|
||||
if (Request.Cookies[cookieName] != null)
|
||||
{
|
||||
Response.Cookies.Append(cookieName, "", cookieOption);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Redirect("/");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" name="submit" id="submit" value="ادامه" /></td>
|
||||
<td colspan="2"><input type="submit" name="submit" id="submit" style="width:100%;background-color:green;color:white" value="ادامه" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div><p style="color:red">@Model.LastError</p></div>
|
||||
@ -103,7 +103,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a role="button" style="cursor: pointer; width: 100%; color: white; background-color: red; display: block" href="/resetpassword">برگشت</a></td>
|
||||
<td><input type="submit" name="submit" id="submit" value="ادامه" /></td>
|
||||
<td><input type="submit" name="submit" id="submit" style="width:100%;background-color:green;color:white" value="ادامه" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div><p style="color:red">@Model.LastError</p></div>
|
||||
@ -138,7 +138,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" name="submit" id="submit" value="ادامه" /></td>
|
||||
<td colspan="2"><input type="submit" name="submit" style="width:100%;background-color:green;color:white" id="submit" value="ادامه" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div><p style="color:red">@Model.LastError</p></div>
|
||||
|
||||
@ -75,10 +75,11 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" name="submit" id="submit" value="ادامه" /></td>
|
||||
<td colspan="2"><input type="submit" name="submit" id="submit" style="width:100%;background-color:green;color:white;text-align:center;cursor:pointer;border-color:white;font-size:2.0em" value="ادامه" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div><p style="color:red">@Model.LastError</p></div>
|
||||
<p>لطفاً به نکات زیر توجه کنید:</p>
|
||||
<p>۱. اگر پیشتر در <a href="https://museum.ganjoor.net">گنجینهٔ گنجور</a> یا <a href="https://gaudiopanel.ganjoor.net">پیشخان خوانشگران گنجور</a> ثبت نام کردهاید میتوانید با همان اطلاعات کاربری در گنجور وارد شوید و نیاز به و امکان ثبت نام مجدد با همان ایمیل را ندارید. </p>
|
||||
<p>۲. برای مطالعهٔ اشعار نیازی به ثبت نام ندارید. ثبت نام برای درج حاشیه و مشارکت در سایت مورد نیاز است.</p>
|
||||
@ -87,7 +88,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div><p style="color:red">@Model.LastError</p></div>
|
||||
|
||||
</form>
|
||||
|
||||
}
|
||||
@ -114,7 +115,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a role="button" style="cursor: pointer; width: 100%; color: white; background-color: red; display: block" href="/signup">برگشت</a></td>
|
||||
<td><input type="submit" name="submit" id="submit" value="ادامه" /></td>
|
||||
<td><input type="submit" name="submit" id="submit" style="width:100%;background-color:green;color:white;text-align:center;cursor:pointer;border-color:white;font-size:2.0em" value="ادامه" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div><p style="color:red">@Model.LastError</p></div>
|
||||
@ -129,7 +130,7 @@
|
||||
<span class="inputlabel">نام: </span>
|
||||
</td>
|
||||
<td>
|
||||
<input asp-for="FinalViewModel.FirstName" placeholder="نام" />
|
||||
<input asp-for="FinalViewModel.FirstName" style="direction:rtl" placeholder="نام" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -137,7 +138,7 @@
|
||||
<span class="inputlabel">نام خانوادگی: </span>
|
||||
</td>
|
||||
<td>
|
||||
<input asp-for="FinalViewModel.SureName" placeholder="نام خانوادگی" />
|
||||
<input asp-for="FinalViewModel.SureName" style="direction:rtl" placeholder="نام خانوادگی" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -165,7 +166,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" name="submit" id="submit" value="ادامه" /></td>
|
||||
<td colspan="2"><input type="submit" name="submit" id="submit" style="width:100%;background-color:green;color:white;text-align:center;cursor:pointer;border-color:white;font-size:2.0em" value="ادامه" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div><p style="color:red">@Model.LastError</p></div>
|
||||
|
||||
@ -488,7 +488,7 @@
|
||||
{
|
||||
<div class="notice" id="commentform">
|
||||
<p>
|
||||
برای حاشیهگذاری باید در گنجور <a href="https://museum.ganjoor.net/signup" target="_blank">ثبت نام</a> کنید و با نام کاربری خود از طریق آیکون 👤 گوشهٔ پایین سمت چپ صفحات به آن وارد شوید.
|
||||
برای حاشیهگذاری باید در گنجور <a href="/signup" target="_blank">ثبت نام</a> کنید و با نام کاربری خود از طریق آیکون 👤 گوشهٔ پایین سمت چپ صفحات به آن وارد شوید.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@ -84,10 +84,10 @@ else
|
||||
<table style="width:100%; margin:0">
|
||||
<tr>
|
||||
<td>
|
||||
<input type="button" onclick="location.href='https://museum.ganjoor.net/signup'" class="cancelbtn" style="width:100%;text-align:center;cursor:pointer" value="ثبت نام" />
|
||||
<input type="button" onclick="location.href='/signup'" class="cancelbtn" style="width:100%;text-align:center;cursor:pointer" value="ثبت نام" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" onclick="location.href='https://museum.ganjoor.net/forgot-password'" class="cancelbtn" style="width:100%;text-align:center;cursor:pointer" value="فراموشی رمز" />
|
||||
<input type="button" onclick="location.href='/resetpassword'" class="cancelbtn" style="width:100%;text-align:center;cursor:pointer" value="فراموشی رمز" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@ -75,10 +75,10 @@ else
|
||||
<table style="width:100%; margin:0">
|
||||
<tr>
|
||||
<td>
|
||||
<input type="button" onclick="location.href='https://museum.ganjoor.net/signup'" class="cancelbtn" style="width:100%;text-align:center;cursor:pointer" value="ثبت نام" />
|
||||
<input type="button" onclick="location.href='/signup'" class="cancelbtn" style="width:100%;text-align:center;cursor:pointer" value="ثبت نام" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" onclick="location.href='https://museum.ganjoor.net/forgot-password'" class="cancelbtn" style="width:100%;text-align:center;cursor:pointer" value="فراموشی رمز" />
|
||||
<input type="button" onclick="location.href='/resetpassword'" class="cancelbtn" style="width:100%;text-align:center;cursor:pointer" value="فراموشی رمز" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user