public async Task <IActionResult> Login() { if (!string.IsNullOrEmpty(Request.QueryString.Value)) { return(RedirectToAction("Login")); } if (_trackerProperties.AllowPublicHistoryAccess) { await PerformAuth("public"); return(RedirectToAction("Pings", "History")); } else { if (string.IsNullOrEmpty(_trackerProperties.EveClientId)) { _logger.LogError("Client ID is not configured"); return(StatusCode(500)); } if (string.IsNullOrEmpty(_trackerProperties.EveClientSecret)) { _logger.LogError("Client Secret is not configured"); return(StatusCode(500)); } var callback = Url.ActionLink("Callback", "Auth", null, Request.Scheme, Request.Host.Value); ViewData["AuthUrl"] = _esiClient.AuthUrl( callback, _trackerProperties.EveClientId); return(View()); } }
public async Task <IActionResult> InitiateStripePayment() { // Load the session booking var sessionBooking = HttpContext.Session.Get <Booking>("Booking"); if (sessionBooking == null) { HttpContext.Session.Set("Booking", new Booking()); sessionBooking = HttpContext.Session.Get <Booking>("Booking"); } // Load the session booking's spots for the displaying of information sessionBooking = await _bookingService.LoadSpots(sessionBooking); // Convert from BookingLines to Stripe's SessionLineItemOptions class var sessionLines = ConvertBookingLinesToSessionLines(bookingLines: sessionBooking.BookingLines); // Set up Stripe's payment session options var options = new SessionCreateOptions { BillingAddressCollection = "required", PaymentMethodTypes = new List <string> { "card", }, LineItems = sessionLines, Mode = "payment", SuccessUrl = Url.ActionLink("SaveBooking", "BookingFlow"), CancelUrl = Url.ActionLink("ShoppingCart", "BookingFlow"), }; var service = new SessionService(); Session session = service.Create(options); return(Json(new { id = session.Id })); }
public async Task <UserDTO> Signup(SignupModel signupModel) { signupModel.ConfirmationLink = Url.ActionLink("ConfirmEmail", "Identity"); await _authService.RegisterUser(signupModel); return(new UserDTO()); }
public async Task <IActionResult> Signup(SignupViewModel model) { if (ModelState.IsValid) { if (await _userManager.FindByEmailAsync(model.Email) == null) { var user = new IdentityUser { Email = model.Email, UserName = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); //Kullanıcıyı tekrar çekerek kullanıcının veritabanında yaratıldığından emin oluyoruz. user = await _userManager.FindByEmailAsync(model.Email); var token = await _userManager.GenerateEmailConfirmationTokenAsync(user); if (result.Succeeded) { var confirmationLink = Url.ActionLink("ConfirmEmail", "Identity", new { userId = user.Id, @token = token }); await _emailSender.SendEmailAsync("*****@*****.**", user.Email, "Confirm your addess", confirmationLink); return(RedirectToAction("Signin")); } ModelState.AddModelError("Signup", string.Join("", result.Errors.Select(x => x.Description))); return(View(model)); } } return(View(model)); }
public async Task <IActionResult> RegisterUserFromGoogle( RegisterUserFromGoogleViewModel model) { if (!ModelState.IsValid) { return(View(model)); } // create claims var claims = new List <Claim>() { new Claim(JwtClaimTypes.Email, model.Email), new Claim(JwtClaimTypes.GivenName, model.GivenName), new Claim(JwtClaimTypes.FamilyName, model.FamilyName), new Claim(JwtClaimTypes.Address, model.Address), new Claim("country", model.Country) }; // provision the user var user = _localUserService. ProvisionUserFromExternalIdentity(model.UserName, model.Email, model.Provider, model.ProviderUserId, claims); await _localUserService.SaveChangesAsync(); //create an activation link var link = Url.ActionLink("ActivateUser", "UserRegistration", new { securityCode = user.SecurityCode }); if (_logger.IsEnabled(LogLevel.Debug)) { _logger.LogDebug(link); } return(View("ActivationCodeSent")); }
public IActionResult OnGet() { var pathByAction = linkGenerator.GetPathByAction("SayHello", "MyRest"); pathByAction = linkGenerator.GetPathByAction("SayHello2", "MyRest"); pathByAction = linkGenerator.GetPathByAction("SayHello", "MyRes2t"); // Rare hamvraag weer, waarom word hier Home genegeeerd? Daarom.. // In TemplateBinder.cs regel 560 word bepaald dat mocht hij hetzelfde zijn als DE default // word het niet opgenomen in de url in sommige gevallen // Denk dat de verwarring is dat dit echt over MVC links gaat, hij doet echt niks met pages var actionLink = Url.ActionLink("Index", "Home"); actionLink = Url.ActionLink("Shit", "Klote"); // Maar hier niet? actionLink = Url.ActionLink("Index", "DitBoeritDusNiet?"); actionLink = Url.ActionLink("Onzin", "DitDus"); actionLink = Url.ActionLink("Index"); actionLink = Url.ActionLink("Privacy"); actionLink = Url.ActionLink("Privacy", "Dondersteen"); actionLink = Url.ActionLink("Privacy", "Home"); _logger.LogInformation("nu dan"); return(Page()); }
public async Task <IActionResult> Signup(SignupViewModel model) { if (ModelState.IsValid) { if ((await _userManager.FindByEmailAsync(model.Email)) != null) { var user = new IdentityUser { Email = model.Email, UserName = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); user = await _userManager.FindByEmailAsync(model.Email); var token = await _userManager.GenerateEmailConfirmationTokenAsync(user); if (result.Succeeded) { var confirmationLink = Url.ActionLink("ConfirmEmail", "Identity", new { userId = user.Id, @token = token }); await emailSender.SendEmailAsync("*****@*****.**", user.Email, "Confirm your email address", confirmationLink); return(RedirectToAction("Signin")); } ModelState.AddModelError("Signup", string.Join("", result.Errors.Select(x => x.Description))); return(View(model)); } } return(View(model)); }
public async Task <IActionResult> CreateBuild([FromForm, Required] CreateBuildRequest request) { using var cover = await SaveTempCover(request.Cover); var result = await _buildService.CreateOrAddVersion(new BuildService.CreateRequest( User.GetUserName(), request.Slug, request.Title, request.Description, request.Tags, (request.Hash, request.Version.Name, request.Version.Description, request.Version.Icons), null), cover, User); return(result switch { BuildService.CreateResult.Success success => Created(Url.ActionLink(nameof(GetDetails), "Build", new { owner = success.Build.OwnerSlug, slug = success.Build.Slug, }), success.Build.ToThinViewModel(Url)), BuildService.CreateResult.DuplicateHash error => Conflict(error.ToProblem()), BuildService.CreateResult.DuplicateSlug error => Conflict(error.ToProblem()), { } error => BadRequest(error.ToProblem()), });
public IActionResult Bind(string userId) { var lineAuthUrl = $"https://notify-bot.line.me/oauth/authorize"; var authParameters = new Dictionary <string, string>() { ["response_type"] = "code", // 固定 ["scope"] = "notify", // 固定 ["client_id"] = LineNotifyConfig.ClientId, // 填寫自己的ClientId }; // 取得並產生LINE Notify授權返回的網址 var bindCallbackUrl = Url.ActionLink(nameof(BindCallback)); // 取得BindCallback這個Action的網址 // 返回網址也要傳送出去 authParameters["redirect_uri"] = bindCallbackUrl; // 狀態值,這個值可以用來防止CSRF攻擊,在本文用來防止返回網址的userId參數被變更(這裡只是簡單做) // 本文只是簡單的做一下HASH來檢查userId是否被竄改等等。 // 這個值將再返回時附加在QueryString中 authParameters["state"] = userId; // 組裝網址 lineAuthUrl = QueryHelpers.AddQueryString(lineAuthUrl, authParameters); // 跳轉畫面到LINE Notify授權畫面 return(Redirect(lineAuthUrl)); }
public async Task <IActionResult> SignUp(SignUpViewModel model) { if (ModelState.IsValid) { if ((await _userManager.FindByEmailAsync(model.Email)) == null) { IdentityUser newUser = new IdentityUser(); newUser.Email = model.Email; newUser.UserName = model.Email; //newUser.PasswordHash = model.Password; IdentityResult result = await _userManager.CreateAsync(newUser, model.Password); var token = await _userManager.GenerateEmailConfirmationTokenAsync(newUser); if (result.Succeeded) { string conformationLink = Url.ActionLink( "ConfirmEmail", "Identity", new { userId = newUser.Id, @token = token }); await _emailSender.SendEmailAsync("*****@*****.**", newUser.Email, "Subject", conformationLink); return(RedirectToAction("Signin")); } ModelState.AddModelError("SignUp", string.Join("", result.Errors.Select(x => x.Description))); return(View(model)); } } return(View(model)); }
private string CreateCallbackUrl(string userId, string codeEncoded, string action) { var args = new { userId = userId, code = codeEncoded }; var callbackUrl = Url.ActionLink(action, "Account", args, HttpContext.Request.Scheme); return(callbackUrl); }
public async Task <IActionResult> Disable2faWarning() { var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } if (!user.TwoFactorEnabled) { throw new ApplicationException( $"Unexpected error occurred disabling 2FA for user with ID '{user.Id}'."); } return(View("Confirm", new ConfirmModel() { Title = $"Disable two-factor authentication (2FA)", DescriptionHtml = true, Description = $"Disabling 2FA does not change the keys used in authenticator apps. If you wish to change the key used in an authenticator app you should <a href=\"{Url.Action(nameof(ResetAuthenticatorWarning))}\"> reset your authenticator keys</a>.", Action = "Disable 2FA", ActionUrl = Url.ActionLink(nameof(Disable2fa)) })); }
public async Task <ReturnStatus> SendEmailVarification(string emailAdress) { ReturnStatus returnStatus = new ReturnStatus() { IsSuccessful = false, }; string confirmationToken = await userSvc.GetVerificationCodeAsync(emailAdress); ShimMathUser user = await userSvc.GetUserByEmailAsync(emailAdress); VerifyEmailModel model = new VerifyEmailModel() { UserName = user.Username, ConfirmationUrl = Url.ActionLink( "ConfirmEmail/" + user.ID + "/" + confirmationToken, "Account", protocol: HttpContext.Request.Scheme), }; string emailView = await ControllerExtensions.RenderViewAsync <VerifyEmailModel>(this, "/Views/Email/VerifyEmail.cshmtl", model, true); if (!string.IsNullOrEmpty(emailView)) { returnStatus = await userSvc.SendVerificationEmailAsync(emailAdress, emailView); } return(returnStatus); }
public async Task <IActionResult> DeleteConfirmed(string id) { var projectionUrlPattern = Url.ActionLink("Index", "Projections"); await filmProjectionBusiness.DeleteAsync(id, projectionUrlPattern); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Register(RegisterVM model) { if (ModelState.IsValid) { var result = await _accountService.RegisterAsync(model); if (result.Succeeded) { _loger.LogInformation(string.Format("The user: {0} is registering.", model.Email)); //send confirmation email var user = await _accountService.GetUserByEmailAsync(model.Email); var token = await _accountService.GenerateConfirmTokenAsync(user); var callBackUrl = Url.ActionLink("Confirmed", "Account", new { Token = token, UserId = user.Id }); var resultEmail = await _emailService.SendConfirmEmailAsync(callBackUrl, user.Email); if (resultEmail) { return(RedirectToAction("Index", "Message", new { Message = IdMessage.SendConfirmEmailSucces })); } _loger.LogError(string.Format("The confirmation Email has not been sent to the user : {0}.", model.Email)); return(RedirectToAction("Index", "Message", new { Message = IdMessage.SendConfirmEmailError })); } result.Errors.ToList().ForEach(e => ModelState.AddModelError("", e.Description)); } return(View(model)); }
public async Task <IActionResult> Fee([FromForm] string type) { var user = await GetCurrentUser(); var(feeStatus, fee) = user.GetFee(type); if (feeStatus != FeeStatus.Unpaid) { return(RedirectToAction(nameof(HomeController.Fees), "Home")); } var sessionId = await _paymentService.CreatePayment( name : user.FullName, email : user.Email, title : fee.Description, description : fee.Description, amount : fee.Amount, successUrl : Url.ActionLink(nameof(FeePaid), "Pay", new { type, sessionId = "{CHECKOUT_SESSION_ID}" }), cancelUrl : Request.GetDisplayUrl(), includesMembership : fee.IncludesMembership, includesTraining : fee.IncludesTraining, includesClasses : fee.IncludesClasses); return(View(new PayModel { Id = sessionId })); }
public async Task <ActionResult <PagedResultModel <UserModel> > > GetAllUsers([FromQuery] UserQueryModel model, CancellationToken cancellationToken) { var query = Context.Users .AsNoTracking() .Include(x => x.OrganizationUnit) .AsQueryable(); if (!string.IsNullOrEmpty(model.OrgUnitPath)) { query = query.Where(x => x.OrganizationUnitPath.StartsWith(model.OrgUnitPath)); } var users = await query .OrderBy(x => x.FamilyName) .ThenBy(x => x.GivenName) .Select(MapToModel) .PagedAsync(model, cancellationToken); foreach (var user in users.Items) { user.PictureUrl = Url.ActionLink(nameof(GetUserPictureById), values: new { id = user.Id }); } return(Ok(users)); }
public Task <ActionResult> Login(string returnUrl) { return(Task.FromResult <ActionResult>(Challenge(new AuthenticationProperties { RedirectUri = Url.ActionLink(nameof(ExternalCallback), "Auth", new { returnUrl }) }))); }
public async Task <IActionResult> Edit(string id, [Bind("Id,Date,ProjecitonType,TotalTickets,FilmId, TicketPrices")] FilmProjection projection) { var projectionInContext = await filmProjectionBusiness.GetAsync(id); if (id != projection.Id || projectionInContext == null) { return(NotFound()); } if (!ModelState.IsValid) { var films = filmDataBusiness.GetAll().ToList().OrderBy(x => x.Title). ToDictionary(x => x.FilmId, x => x.Title); ViewBag.SelectListOfFilms = new SelectList(films, "Key", "Value"); return(View(projection)); } var ticketUrlPattern = Url.ActionLink("Index", "Tickets"); var projecitonsUrlPattern = Url.ActionLink("Index", "Projections"); projection.CinemaId = projectionInContext.CinemaId; await filmProjectionBusiness.UpdateAsync(projection, projecitonsUrlPattern, ticketUrlPattern); return(RedirectToAction(nameof(Details), new { id })); }
public async Task <IActionResult> OnPost([FromBody] DAL.Models.Task task) { await _context.Tasks.AddAsync(task); await _context.SaveChangesAsync(); return(Created(Url.ActionLink(nameof(OnGet), null, new { id = task.Id }), task)); }
public ActionResult GenerateUrl(string q) { string path = Url.ActionLink("Index", "Home", new { q }, "https", Request.Host.Value); string tinyUrl = GenerateTinyUrl(path); return(PartialView("_GenerateUrl", new GeneratedUrlModel { Url = path, TinyUrl = tinyUrl })); }
private string SignupSuccessLink(Guid id) => Url.ActionLink( nameof(Success), "Signup", new { id, sessionId = "{CHECKOUT_SESSION_ID}" });
public async Task <ActionResult> Register([FromBody] RegisterModel model) { List <IdentityError> errors = new List <IdentityError>(); // verify the data if (ModelState.IsValid) { //if the data are valid create the user var user = new IdentityUser() { UserName = model.Username, Email = model.Email, EmailConfirmed = false, }; var result = await this._userManager.CreateAsync(user, model.Password); if (result.Succeeded) { var role = await this._roleManager.FindByIdAsync(model.Role); if (role == null) { await this._roleManager.CreateAsync(new IdentityRole() { Name = model.Role, NormalizedName = model.Role.ToUpper() }); } await this._userManager.AddToRoleAsync(user, role.NormalizedName); /* send email confirmation */ // Generate Email token var mailToken = await this._userManager.GenerateEmailConfirmationTokenAsync(user); // Generate Url var link = Url.ActionLink(nameof(VerifyEmail), "account", new { userId = user.Id, mailToken }, Request.Scheme, Request.Host.ToString()); // Send the mail await this._emailService.SendAsync("*****@*****.**", "Email Verification", $"<a href=\"{link}\">Verify Email</a>", true); // and return a 201 created user return(CreatedAtAction(nameof(Register), new { Usename = user.UserName, Email = user.Email, EmailConfirmed = user.EmailConfirmed, role })); } else { foreach (var error in result.Errors) { errors.Add(error); } // else return a bad request return(BadRequest(errors)); } } else { return(BadRequest("Check user info ! error occured when creating the user")); } }
public async Task <IActionResult> OnPostExternalLoginAsync(string provider) { await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); // Request a redirect to the external login provider var redirectUrl = Url.ActionLink("LinkLoginCallback", "Account"); var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl, _userManager.GetUserId(User)); return(new ChallengeResult(provider, properties)); }
public IActionResult Index() { var datatableModel = _dataTableHelper. Initiate(Url.ActionLink("Search", "Products", null)) .GetFeilds(typeof(ProductViewModel)) .AddExtraHeader("Actions") .CreateDataTable(); return(View(datatableModel)); }
public async Task <IActionResult> Register(Registration registrationParams) { if (registrationParams.Password != registrationParams.RetypedPassword) { ModelState.AddModelError(string.Empty, "Passwords don't match"); return(View("Register", registrationParams)); } IdentityUser newUser = new IdentityUser { UserName = registrationParams.Email, Email = registrationParams.Email }; var userCreationResult = await _userManager.CreateAsync(newUser, registrationParams.Password); if (userCreationResult.Succeeded) { var confirmationToken = await _userManager.GenerateEmailConfirmationTokenAsync(newUser); var webEncodedConfirmationToken = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(confirmationToken)); var callbackUrl = Url.ActionLink(action: "VerifyEmail", controller: "Account", values: new { id = newUser.Id, token = confirmationToken }); await _emailServer.SendEmailAsync(newUser.Email, "Email confirmation", callbackUrl); //Send email with confirmation link and token //Redirect to useful page } else { foreach (var error in userCreationResult.Errors) { ModelState.AddModelError(string.Empty, error.Description); } return(View("Register", registrationParams)); } //await _userManager.AddClaimAsync(newUser, new Claim(ClaimTypes.Role, "IdentityUser")); //string emailConfirmationToken = await _userManager.GenerateEmailConfirmationTokenAsync(newUser); //string tokenVerificationUrl = Url.Action("VerifyEmail", "Registrations", new { id = newUser.Id, token = emailConfirmationToken }, Request.Scheme); //// //LocalEmailClient.SendEmail("email confirmation", "Account", "VerifyEmail", tokenVerificationUrl); //await _messageService.Send(email, "Verify your email", $"Click <a href=\"{tokenVerificationUrl}\">here</a> to verify your email"); //return Content("Check your email for a verification link"); //return RedirectToAction(actionName: "Index", controllerName: "Users"); return(RedirectToAction(actionName: "Index", controllerName: "Home")); }
private async Task SendConfirmationEmail(IdentityUser user, string returnUrl) { var emailConfirmationToken = await _userManager.GenerateEmailConfirmationTokenAsync(user); emailConfirmationToken = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(emailConfirmationToken)); await _emailService.SendFromDoNotReplyAsync( user.Email, "Stack Underflow - Confirm Account", Url.ActionLink("Activate", "Activation", new { userId = user.Id, token = emailConfirmationToken, returnUrl }) ); }
/// <summary> /// For external login /// </summary> /// <param name="provider"></param> /// <returns></returns> public async Task <IActionResult> OnPostExternalLogin(string provider) { // Clear the existing external cookie to ensure a clean login process await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); // Request a redirect to the external login provider to link a login for the current user var redirectUrl = Url.ActionLink("LinkLoginCallback", "Account");//Url.Action(nameof(OnGetLoginCallback)); var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl, _userManager.GetUserId(User)); return(new ChallengeResult(provider, properties)); }
/// <summary> /// DTO Annotations Mapper used with GET annotation /// </summary> /// <param name="annotation"></param> /// <returns>AnnotationsDto</returns> private AnnotationsDto CreateLink(Annotations annotation) { var annotationDto = _mapper.Map <AnnotationsDto>(annotation); annotationDto.AnnotationId = annotation.Id; annotationDto.URL = Url.Link( nameof(GetAnyAnnotationById), new { AnnotationId = annotation.Id }); annotationDto.AddAnnotationUrl = Url.ActionLink(nameof(AddAnnotation)); return(annotationDto); }
//Email send message Password Change public async Task <IActionResult> Check(string checkemail) { var callbackUrl = Url.ActionLink( "ChangePassword", "Account", new { email = checkemail }, protocol: HttpContext.Request.Scheme); EmailServices emailServices = new EmailServices(); await emailServices.SendEmailAsync(checkemail, "Password Deyismek ucun linke click edin", $"Password Change:<a href='{callbackUrl}'>Link</a>" ); return(RedirectToAction("Login", "Account")); }