public async Task <IActionResult> Register(AppUserRegisterModel model) { if (ModelState.IsValid) { var user = new AppUser() { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, UserName = model.UserName }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await _userManager.AddToRoleAsync(user, "Member"); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var url = Url.Action("ConfirmAccount", "Dashboard", new { Area = "", userId = user.Id, token = code }); await _emailSender.EmailSenderAsycn(model.Email, $"Hesap Doğrulama", $"Lütfen hesabınızı onaylamak için <a href='websiteadress{url}'>buraya</a> tıklayınız!"); return(RedirectToAction("Index", "User", new { area = "Admin" })); } } return(View(model)); }
public async Task REGISTER_AND_LOGIN_USER_PASS() { var registerModel = new AppUserRegisterModel { Email = "*****@*****.**", Password = "******", Name = "mo3in" }; var response = await Client.PostAsJsonAsync("/api/account/register", registerModel); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var loginModel = new LoginVM { Email = "*****@*****.**", Password = "******" }; response = await Client.PostAsJsonAsync("/api/account/Login", loginModel); var result = await response.Content.ReadAsAsync <BearerLoginResult>(); Assert.Equal(3, result.access_token.Split(".").Length); }
public async Task <string> SignUp(AppUserRegisterModel model) { MultipartFormDataContent formDataContent = new MultipartFormDataContent(); formDataContent.Add(new StringContent(model.UserName), nameof(AppUserRegisterModel.UserName)); formDataContent.Add(new StringContent(model.Password), nameof(AppUserRegisterModel.Password)); formDataContent.Add(new StringContent(model.Email), nameof(AppUserRegisterModel.Email)); formDataContent.Add(new StringContent(model.FullName), nameof(AppUserRegisterModel.FullName)); var responseMessage = await _httpClient.PostAsync("SignUp", formDataContent); if (!responseMessage.IsSuccessStatusCode) { return("Sistemde bu kullanıcı adını veya email'ini kullanan birisi var. Lütfen başka bir kullanıcı adı veya email dene."); } else { return(""); } }
public async Task <IActionResult> SignUp(AppUserRegisterModel model) { if (ModelState.IsValid) { string message = await _authService.SignUp(model); if (string.IsNullOrWhiteSpace(message)) { TempData["Kayit"] = "KayıtOlundu!"; return(RedirectToAction("LogIn", "Auth")); } else { ModelState.AddModelError("", message); return(View(model)); } } else { return(View(model)); } }