diff --git a/GanjooRazor/Pages/SignUp.cshtml b/GanjooRazor/Pages/SignUp.cshtml index 4c434cc3..9c8c5c41 100644 --- a/GanjooRazor/Pages/SignUp.cshtml +++ b/GanjooRazor/Pages/SignUp.cshtml @@ -24,6 +24,7 @@ } else + if (Model.SignupPhase1) {
@@ -41,6 +42,9 @@ @@ -55,14 +59,39 @@ - - -
+ + +
-
@Model.LastError
+

@Model.LastError

} + else + if (Model.SignupVerifyEmailPhase) + { +
+ + + + + + + + + + + + +
+

لطفا پست الکترونیکی خود را بررسی کنید. در صورتی که نشانی پست الکترونیکی خود را درست وارد کرده باشید نامه‌ای از گنجور دریافت کرده‌اید که حاوی یک رمز است.

+

رمز دریافتی را در کادر زیر وارد کرده، روی دکمهٔ «ادامه» کلیک کنید

+

تذکر: ممکن است نامه به پوشه اسپم منتقل شده باشد

+
+ رمز دریافتی: + + +
+

@Model.LastError

+
+ } diff --git a/GanjooRazor/Pages/SignUp.cshtml.cs b/GanjooRazor/Pages/SignUp.cshtml.cs index a8945b56..c586cb33 100644 --- a/GanjooRazor/Pages/SignUp.cshtml.cs +++ b/GanjooRazor/Pages/SignUp.cshtml.cs @@ -1,9 +1,10 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Newtonsoft.Json; using RSecurityBackend.Models.Auth.ViewModels; using System; using System.Net.Http; +using System.Text; using System.Threading.Tasks; namespace GanjooRazor.Pages @@ -25,14 +26,32 @@ namespace GanjooRazor.Pages public string CaptchaImageUrl { get; set; } + + public bool SignupPhase1 { get; set; } + + public bool SignupVerifyEmailPhase { get; set; } + + public bool SignupFinalPhase { get; set; } + [BindProperty] public UnverifiedSignUpViewModel SignUpViewModel { get; set; } + + [BindProperty] + public string Secret { get; set; } public async Task OnGetAsync() { LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Name"]); - LastError = Request.Query["error"]; + LastError = ""; + SignupPhase1 = true; + SignupVerifyEmailPhase = false; + SignupFinalPhase = false; - SignUpViewModel = new UnverifiedSignUpViewModel(); + SignUpViewModel = new UnverifiedSignUpViewModel() + { + ClientAppName = "وبگاه گنجور", + Language = "fa-IR", + CallbackUrl = "https://ganjoor.net/signup" + }; var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/users/captchaimage"); response.EnsureSuccessStatusCode(); @@ -41,6 +60,27 @@ namespace GanjooRazor.Pages CaptchaImageUrl = $"{APIRoot.InternetUrl}/api/rimages/{SignUpViewModel.CaptchaImageId}.jpg"; + return Page(); + } + + public async Task OnPostAsync(UnverifiedSignUpViewModel SignUpViewModel) + { + LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Name"]); + LastError = ""; + SignupPhase1 = true; + SignupVerifyEmailPhase = false; + SignupFinalPhase = false; + + var response = await _httpClient.PostAsync($"{APIRoot.Url}/api/users/signup", new StringContent(JsonConvert.SerializeObject(SignUpViewModel), Encoding.UTF8, "application/json")); + if(!response.IsSuccessStatusCode) + { + LastError = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + return Page(); + } + SignupPhase1 = false; + SignupVerifyEmailPhase = true; + + return Page(); } } diff --git a/RSecurityBackend/Controllers/AppUserControllerBase.cs b/RSecurityBackend/Controllers/AppUserControllerBase.cs index a605bc61..df7ebf22 100644 --- a/RSecurityBackend/Controllers/AppUserControllerBase.cs +++ b/RSecurityBackend/Controllers/AppUserControllerBase.cs @@ -968,7 +968,7 @@ namespace RSecurityBackend.Controllers } /// - /// verify signup / forgot password + /// verify signup / forgot password / self delete user /// /// /// diff --git a/RSecurityBackend/RSecurityBackend.xml b/RSecurityBackend/RSecurityBackend.xml index 65e67ed1..9f58d82b 100644 --- a/RSecurityBackend/RSecurityBackend.xml +++ b/RSecurityBackend/RSecurityBackend.xml @@ -231,7 +231,7 @@ - verify signup / forgot password + verify signup / forgot password / self delete user