public async Task <ActionResult> SubmitForVerification(int id, string title) { if (!CurrentUser.HasAccess(UserAccess.CourseCreate) && !CurrentUser.HasAccess(UserAccess.CourseEdit)) { return(new HttpUnauthorizedResult()); } var model = new CourseApprovalLogModel { CreatedBy = CurrentUser.UserId.Value, CreatedByName = CurrentUser.Name, CourseId = id, }; var response = await WepApiMethod.SendApiAsync <CourseApprovalLogModel>(HttpVerbs.Post, CourseApprovalApiUrl.SubmitForVerification, model); if (response.isSuccess) { await LogActivity(Modules.Learning, "Successfully submit Course For Verification. Course : " + title); await Notifier.SubmitCourseForVerication(id, CurrentUser.UserId.Value, "", CurrentUser.Name, title, Url.AbsoluteAction("Approve", "CourseApprovals", new { id = id })); TempData["SuccessMessage"] = $"The Course {title} has been successfully submitted for verification."; } else { await LogActivity(Modules.Learning, "Error submit Course For Verification. Course : " + title); TempData["ErrorMessage"] = $"Error submitting the course {title} for verification."; } return(RedirectToAction("Content", "Courses", new { area = "eLearning", @id = id })); }
public ActionResult Remind(RemindViewModel model, string returnUrl) { if (ModelState.IsValid) { User user = repo.User(email: model.Email); string randomToken = textBuilder.GetRandomString(50); UserToken userToken = account.GetNewUserToken(repo, user, randomToken); string action = Url.AbsoluteAction("Reset", "Account", new { token = randomToken }, repoConfig); if (userToken != null) { if (account.SendRemindUserEmail(model, action, user)) { this.SetMessage(InfoMessageType.Success, Resources.SentLinkFurther); } else { this.SetMessage(InfoMessageType.Danger, Resources.SentLinkProblem); } } else { this.SetMessage(InfoMessageType.Danger, Resources.NoUserEmail); } } return(Redirect(returnUrl ?? Url.Action("Index", "Home"))); }
public virtual async Task <ActionResult> Index() { var user = await _queries.Execute(new UserViewBy(User.Identity.GetUserId <int>())); var emails = await _queries.Execute(new EmailAddressViewsBy(User.Identity.GetUserId <int>()) { OrderBy = new Dictionary <Expression <Func <EmailAddressView, object> >, OrderByDirection> { { x => x.IsPrimary, OrderByDirection.Descending }, { x => x.IsVerified, OrderByDirection.Descending }, }, }); var model = new EmailAddressSettingsModel { UserView = user, EmailAddresses = emails.ToArray(), SendVerificationEmail = new SendVerificationEmail { Purpose = EmailVerificationPurpose.AddEmail, SendFromUrl = Url.AbsoluteAction(await MVC.UserEmails.Index()), VerifyUrlFormat = Url.AbsoluteActionFormat(await MVC.UserEmailConfirm.Index("{0}", "{1}")), }, }; ViewBag.ActionUrl = Url.Action(MVC.UserEmails.Post()); ViewBag.Purpose = model.SendVerificationEmail.Purpose; return(View(MVC.Security.Views.User.EmailAddresses, model)); }
public IActionResult AbsoluteAction() { return(new ContentResult() { Content = Url.AbsoluteAction("AbsoluteAction", "UrlHelper") }); }
public async Task <IActionResult> SubmitUpdateAccount(GoblinIdentityUpdateIdentityModel model, CancellationToken cancellationToken = default) { if (!ModelState.IsValid) { ViewBag.WarningMessage = Messages.InvalidData; return(View("Account", model)); } try { await GoblinIdentityHelper.UpdateIdentityAsync(LoggedInUser <GoblinIdentityUserModel> .Current.Data.Id, model, cancellationToken).ConfigureAwait(true); ViewBag.SuccessMessage = "Account Updated Successfully."; if (!string.IsNullOrWhiteSpace(model.NewPassword)) { return(View("~/Views/Auth/Login.cshtml", new LoginModel { Continue = Url.AbsoluteAction("Account", "Portal") })); } } catch (GoblinException e) { ViewBag.ErrorMessage = e.ErrorModel.Message; } catch (Exception e) { ViewBag.ErrorMessage = e.Message; } return(View("Account", model)); }
public async Task <ActionResult> Login([Bind(Include = "UserName,Password,RememberMe,Back")] LoginVM vm) { var status = await _repository.Auth.Login(vm); string url; switch (status) { case SignInStatus.Success: url = BuildUrl(vm.Back); return(JsonNet(Message.Ok.ToRedirectResponse(url))); case SignInStatus.LockedOut: url = Url.AbsoluteAction("Lockout", "Page", new { area = "" }); return(JsonNet(Message.Error.ToRedirectResponse(url))); case SignInStatus.RequiresVerification: url = Url.AbsoluteAction("SendCode", "Page", new { area = "" }); return(JsonNet(Message.Error.ToRedirectResponse(url))); case SignInStatus.Failure: default: var msg = Utilities.Resx <Resources.Messages> .Get["ErrorLoginFailed"]; return(JsonNet(Message.Error.ToResultResponse(msg))); //throw new System.NotImplementedException(); } }
/// <summary> /// Open the course to public. Check whether there are existing public course event and its status /// If so, decide to reuse or not /// Enrollment code is /// </summary> /// <param name="id">CourseId</param> /// <returns></returns> /// public async Task <ActionResult> Publish(int id, string title, ViewCategory viewCategory) { var createdBy = CurrentUser.UserId; var response = await WepApiMethod.SendApiAsync <ChangeCourseStatusModel>(HttpVerbs.Post, CourseEventApiUrl.Publish + $"?id={id}&createdBy={createdBy}"); if (response.isSuccess) { await LogActivity(Modules.Learning, $"Success publishing - Course - {id}-{title}"); await Notifier.NotifyCoursePublish(NotificationType.Course_Publish, id, CurrentUser.UserId.Value, "", createdBy.ToString(), title, Url.AbsoluteAction("Content", "Course", new { id = id })); if (viewCategory == ViewCategory.Public) { TempData["SuccessMessage"] = $"Course titled {title} published successfully and open for public."; } else { TempData["SuccessMessage"] = $"Course titled {title} published successfully.You can now invite group / students to enroll to the course."; } } else { await LogError(Modules.Learning, $"Error publishing - Course - {id}-{title}"); TempData["ErrorMessage"] = $"Error publishing the course {title}."; } return(RedirectToAction("Content", "Courses", new { area = "eLearning", id = id })); }
public ActionResult Products() { var sitemapItems = new List <SitemapItem>(); String key = String.Format("ProductSitemapItemCache-{0}", StoreId); ProductSitemapItemCache.TryGet(key, out sitemapItems); if (sitemapItems == null) { sitemapItems = new List <SitemapItem>(); var products = ProductRepository.GetProductByTypeAndCategoryIdFromCache(StoreId, StoreConstants.ProductType, -1); var categories = ProductCategoryService.GetProductCategoriesByStoreIdFromCache(StoreId, StoreConstants.ProductType); foreach (var product in products) { var cat = categories.FirstOrDefault(r => r.Id == product.ProductCategoryId); if (cat != null) { var productDetailLink = LinkHelper.GetProductIdRouteValue(product, cat.Name); var siteMap = new SitemapItem(Url.AbsoluteAction("Product", "Products", new { id = productDetailLink }), changeFrequency: SitemapChangeFrequency.Monthly, priority: 1.0); sitemapItems.Add(siteMap); } } ProductSitemapItemCache.Set(key, sitemapItems, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.CacheLongSeconds)); } return(new SitemapResult(sitemapItems)); }
public async Task <IActionResult> Create( long id, [FromHeader(Name = Http.HeaderNames.AmsAuthor)] string author, [FromHeader(Name = Http.HeaderNames.AmsAuthorLogin)] string authorLogin, [FromHeader(Name = Http.HeaderNames.AmsAuthorName)] string authorName, [FromBody] IObjectDescriptor objectDescriptor) { if (string.IsNullOrEmpty(author) || string.IsNullOrEmpty(authorLogin) || string.IsNullOrEmpty(authorName)) { return(BadRequest( $"'{Http.HeaderNames.AmsAuthor}', '{Http.HeaderNames.AmsAuthorLogin}' and '{Http.HeaderNames.AmsAuthorName}' " + "request headers must be specified.")); } if (TryGetModelErrors(out var errors)) { return(BadRequest(errors)); } try { var versionId = await _objectsManagementService.Create(id, new AuthorInfo(author, authorLogin, authorName), objectDescriptor); var url = Url.AbsoluteAction("GetVersion", "Objects", new { id, versionId }); Response.Headers[HeaderNames.ETag] = $"\"{versionId}\""; return(Created(url, null)); } catch (InvalidObjectException ex) { return(Unprocessable(ex.SerializeToJson())); } catch (ObjectNotFoundException ex) { _logger.LogError(default, ex, "Error occured while creating object");
public async Task <IActionResult> SetupSession( [FromHeader(Name = Http.HeaderNames.AmsAuthor)] string author, [FromHeader(Name = Http.HeaderNames.AmsAuthorLogin)] string authorLogin, [FromHeader(Name = Http.HeaderNames.AmsAuthorName)] string authorName, Language language, long templateId) { if (string.IsNullOrEmpty(author) || string.IsNullOrEmpty(authorLogin) || string.IsNullOrEmpty(authorName)) { return(BadRequest( $"'{Http.HeaderNames.AmsAuthor}', '{Http.HeaderNames.AmsAuthorLogin}' and '{Http.HeaderNames.AmsAuthorName}' " + "request headers must be specified.")); } try { var sessionId = Guid.NewGuid(); await _sessionManagementService.Setup(sessionId, templateId, null, language, new AuthorInfo(author, authorLogin, authorName)); var url = Url.AbsoluteAction("Get", "Sessions", new { sessionId }); Response.Headers[HeaderNames.ETag] = $"\"{sessionId}\""; return(Created(url, null)); } catch (ObjectNotFoundException ex) { return(NotFound(ex.Message)); } catch (SessionCannotBeCreatedException ex) { return(BadRequest(ex.Message)); } }
public async Task <ActionResult> Brands() { var sitemapItems = new List <SitemapItem>(); String key = String.Format("BrandsSiteMap-{0}", StoreId); ProductSitemapItemCache.TryGet(key, out sitemapItems); if (sitemapItems == null) { sitemapItems = new List <SitemapItem>(); var brandsTask = BrandService.GetBrandsAsync(StoreId, null, true); await Task.WhenAll(brandsTask); var brands = brandsTask.Result; foreach (var brand in brands) { var brandDetailLink = LinkHelper.GetBrandIdRouteValue(brand); var siteMap = new SitemapItem(Url.AbsoluteAction("detail", "brands", new { id = brandDetailLink }), changeFrequency: SitemapChangeFrequency.Monthly, priority: 1.0); sitemapItems.Add(siteMap); } ProductSitemapItemCache.Set(key, sitemapItems, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.CacheLongSeconds)); } return(new SitemapResult(sitemapItems)); }
public async Task <IActionResult> Index() { var viewModel = new AuthViewModel { PlexKey = HttpContext.Session.GetString("PlexKey"), TraktKey = HttpContext.Session.GetString("TraktKey"), PlexServerKey = HttpContext.Session.GetString("PlexServerKey") }; if (!string.IsNullOrEmpty(viewModel.PlexKey) && !string.IsNullOrEmpty(viewModel.TraktKey)) { _plexClient.SetAuthToken(viewModel.PlexKey); viewModel.PlexServers = (await _plexClient.GetServers()).Select(x => new SelectListItem { Value = x.Url, Text = x.Name }).ToList(); if (viewModel.PlexServers.Any()) { viewModel.PlexServers[0].Selected = true; } } var traktRedirectUrl = HttpUtility.UrlEncode(Url.AbsoluteAction("TraktReturn", "Home")); ViewData["TraktUrl"] = $"https://trakt.tv/oauth/authorize?client_id={_config["TraktConfig:ClientId"]}&redirect_uri={traktRedirectUrl}&response_type=code"; return(View(viewModel)); }
public IActionResult PspSender() { var data = this._pspProcessor.PrepData(Url.AbsoluteAction("PspCallback", "Hidden")); var model = new PspSenderModel(Url.AbsoluteAction("PspGateway", "Proxy"), data.ToImmutableDictionary()); return(this.View(model)); }
public async Task <IActionResult> Subscribe(string email) { var subscriber = newsletterCuratorContext.Subscribers.SingleOrDefault(s => s.Email.Equals(email)); if (subscriber == null) { subscriber = new Subscriber { ID = Guid.NewGuid(), Email = email, DateSubscribed = DateTimeOffset.UtcNow }; await newsletterCuratorContext.Subscribers.AddAsync(subscriber); } else { subscriber.DateUnsubscribed = null; subscriber.DateValidated = null; } await newsletterCuratorContext.SaveChangesAsync(); await emailService.SendValidationEmailAsync(email, Url.AbsoluteAction("Validate", "Newsletter", new { id = subscriber.ID })); telemetryClient.TrackEvent("UserSubscribed"); return(View(true)); }
public async Task <IActionResult> SigninCallback() { _log.Info("Start getting user session."); var userSession = await _userSessionManager.GetUserSession(); if (userSession == null) { _log.Warning(SessinNotExistMessage); return(BadRequest(SessinNotExistMessage)); } var authCode = HttpContext.Request.Query["code"]; var tokens = await GetTokens(authCode, _ironcladSettings.AuthClient, Url.AbsoluteAction("SigninCallback", "Callback")); var userId = GetUserId(tokens.IdentityToken); var authResult = await _clientSessionsClient.Authenticate(userId, "hobbit"); SaveAuthResult(userSession, authResult); SaveTokensToUserSession(userSession, tokens); await SaveLykkeSession(authResult.SessionToken, tokens); await _userSessionManager.SetUserSession(userSession); var query = GetAuthorizeQueryAsync(userSession); var redirectUri = BuildFragmentRedirectUri(query, tokens); _log.Info("Redirecting to client app redirect uri. RedirectUri:{RedirectUri}", redirectUri); return(Redirect(redirectUri)); }
public async Task <ActionResult> CancelCourse(int?id, string title = "") { if (id == null) { TempData["ErrorMessage"] = "Cannot find such course."; return(RedirectToAction("Index", "Courses", new { area = "eLearning" })); } var response = await WepApiMethod.SendApiAsync <string>(HttpVerbs.Post, CourseApiUrl.CancelCourse + $"?id={id}"); if (response.isSuccess) { await LogActivity(Modules.Learning, $"Cancel Course titled {title} Success: " + response.Data, CurrentUser.UserId.Value); TempData["SuccessMessage"] = $"Creation of course titled {title} is successfully cancelled."; await Notifier.NotifyCourseCancelled(NotificationType.Course_Cancelled, id.Value, CurrentUser.UserId.Value, "", "", title, Url.AbsoluteAction("Index", "Courses", new { area = "eLearning" })); } else { TempData["ErrorMessage"] = $"Failed to Cancel Course {title}."; } return(RedirectToAction("Index", "Courses", new { area = "eLearning" })); }
public async Task <IActionResult> Create( long id, [FromHeader(Name = Http.HeaderNames.AmsAuthor)] string author, [FromHeader(Name = Http.HeaderNames.AmsAuthorLogin)] string authorLogin, [FromHeader(Name = Http.HeaderNames.AmsAuthorName)] string authorName, [FromBody] IObjectDescriptor objectDescriptor) { if (string.IsNullOrEmpty(author) || string.IsNullOrEmpty(authorLogin) || string.IsNullOrEmpty(authorName)) { return(BadRequest( $"'{Http.HeaderNames.AmsAuthor}', '{Http.HeaderNames.AmsAuthorLogin}' and '{Http.HeaderNames.AmsAuthorName}' " + "request headers must be specified.")); } if (objectDescriptor == null) { return(BadRequest("Object descriptor must be set.")); } try { var versionId = await _objectsManagementService.Create(id, new AuthorInfo(author, authorLogin, authorName), objectDescriptor); var url = Url.AbsoluteAction("GetVersion", "Objects", new { id, versionId }); Response.Headers[HeaderNames.ETag] = $"\"{versionId}\""; return(Created(url, null)); } catch (InvalidObjectException ex) { return(Unprocessable(ex.SerializeToJson())); } catch (ObjectNotFoundException ex) { _logger.LogError(new EventId(), ex, "Error occured while creating object"); return(Unprocessable(ex.Message)); } catch (ObjectAlreadyExistsException) { return(Conflict("Object with the same id already exists")); } catch (LockAlreadyExistsException) { return(Conflict("Simultaneous creation of object with the same id")); } catch (InvalidOperationException ex) { _logger.LogError(new EventId(), ex, "Error occured while creating object"); return(BadRequest(ex.Message)); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } catch (ObjectInconsistentException ex) { return(BadRequest(ex.Message)); } }
private string GetPostLink(Post post) { if (post.Id == null) // invalid feed { return(Url.AbsoluteAction("Index", "Posts")); } return(Url.AbsoluteAction("Details", "PostDetails", new { Id = RavenIdResolver.Resolve(post.Id), Slug = SlugConverter.TitleToSlug(post.Title), Key = post.ShowPostEvenIfPrivate })); }
private string BuildUrl(string back = "") { if (Url.IsLocalUrl(back)) { return(back); } return(Url.AbsoluteAction("Dashboard", "page")); }
public async Task <IActionResult> PlexLogin() { var redirectUrl = Url.AbsoluteAction("PlexReturn", "Home"); var oauthUrl = await _plexClient.GetOAuthUrl(redirectUrl); HttpContext.Session.SetString("PlexOauthId", oauthUrl.Id); return(Redirect(oauthUrl.Url)); }
public virtual ViewResult Index(string returnUrl) { ViewBag.ReturnUrl = returnUrl; ViewBag.ActionUrl = Url.Action(MVC.SignUpSendEmail.Post()); ViewBag.Purpose = EmailVerificationPurpose.CreateLocalUser; ViewBag.VerifyUrlFormat = Url.AbsoluteActionFormat(MVC.SignUpCreateUser.Index("{0}", "{1}", returnUrl).Result); ViewBag.SendFromUrl = Url.AbsoluteAction(MVC.SignUpSendEmail.Index(returnUrl)); return(View(MVC.Security.Views.SignUp.SendEmail)); }
public async Task <IActionResult> SubmitLogin([FromForm] LoginModel model, CancellationToken cancellationToken = default) { if (LoggedInUser <GoblinIdentityUserModel> .Current?.Data != null) { if (!string.IsNullOrWhiteSpace(model.Continue)) { return(Redirect(model.Continue)); } return(RedirectToAction("Index", "Home")); } if (!ModelState.IsValid) { ViewBag.WarningMessage = Messages.InvalidData; return(View("Login", model)); } if (string.IsNullOrWhiteSpace(model.Continue)) { model.Continue = Url.AbsoluteAction("Index", "Home"); } ViewBag.ContinueUrl = model.Continue; try { var generateAccessTokenModel = new GoblinIdentityGenerateAccessTokenModel { UserName = model.UserName, Password = model.Password }; var accessToken = await GoblinIdentityHelper.GenerateAccessTokenAsync(generateAccessTokenModel, cancellationToken); accessToken = accessToken?.Trim('"'); CookieHelper.SetShare(HttpContext, GoblinCookieKeys.AccessToken, accessToken); return(View("LoggedIn")); } catch (GoblinException e) { ViewBag.ErrorMessage = e.ErrorModel.Message; return(View("Login", model)); } catch (Exception e) { ViewBag.ErrorMessage = e.Message; return(View("Login", model)); } }
private async Task <IActionResult> ModifyInternal( long id, string ifMatch, string author, string authorLogin, string authorName, ITemplateDescriptor templateDescriptor, Func <TemplateValidationException, JToken> errorGenerator) { if (string.IsNullOrEmpty(ifMatch)) { return(BadRequest($"'{HeaderNames.IfMatch}' request header must be specified.")); } if (string.IsNullOrEmpty(author) || string.IsNullOrEmpty(authorLogin) || string.IsNullOrEmpty(authorName)) { return(BadRequest( $"'{Http.HeaderNames.AmsAuthor}', '{Http.HeaderNames.AmsAuthorLogin}' and '{Http.HeaderNames.AmsAuthorName}' " + "request headers must be specified.")); } if (templateDescriptor == null) { return(BadRequest("Template descriptor must be set.")); } try { var latestVersionId = await _templatesManagementService.ModifyTemplate( id, ifMatch.Trim('"'), new AuthorInfo(author, authorLogin, authorName), templateDescriptor); var url = Url.AbsoluteAction("GetVersion", "Templates", new { id, versionId = latestVersionId }); Response.Headers[HeaderNames.ETag] = $"\"{latestVersionId}\""; return(NoContent(url)); } catch (ObjectNotFoundException) { return(NotFound()); } catch (TemplateValidationException ex) { return(Unprocessable(errorGenerator(ex))); } catch (LockAlreadyExistsException) { return(Locked("Simultaneous modification of template")); } catch (ConcurrencyException) { return(PreconditionFailed()); } }
public virtual ActionResult Index(string returnUrl) { ViewBag.ReturnUrl = returnUrl; ViewBag.Purpose = EmailVerificationPurpose.ForgotPassword; ViewBag.VerifyUrlFormat = Url.AbsoluteActionFormat( MVC.ResetPassword.Index("{0}", "{1}", returnUrl).Result); ViewBag.SendFromUrl = Url.AbsoluteAction( MVC.ResetPasswordSendEmail.Index(returnUrl)); return(View(MVC.Security.Views.ResetPassword.SendEmail)); }
public ActionResult Rss(string tag, Guid key) { RavenQueryStatistics stats; var postsQuery = RavenSession.Query <Post>() .Statistics(out stats); if (key != Guid.Empty && key == BlogConfig.RssFuturePostsKey) { postsQuery = postsQuery.Where(x => x.PublishAt < DateTimeOffset.Now.AddDays(BlogConfig.RssFutureDaysAllowed).AsMinutes()); } else { postsQuery = postsQuery.Where(x => x.PublishAt < DateTimeOffset.Now.AsMinutes()); } if (string.IsNullOrWhiteSpace(tag) == false) { postsQuery = postsQuery.Where(x => x.TagsAsSlugs.Any(postTag => postTag == tag)); } var posts = postsQuery.OrderByDescending(x => x.PublishAt) .Take(20) .ToList(); string responseETagHeader; if (CheckEtag(stats, out responseETagHeader)) { return(HttpNotModified()); } var rss = new XDocument( new XElement("rss", new XAttribute("version", "2.0"), new XElement("channel", new XElement("title", BlogConfig.Title), new XElement("link", Url.RelativeToAbsolute(Url.RouteUrl("Default"))), new XElement("description", BlogConfig.MetaDescription ?? BlogConfig.Title), new XElement("copyright", String.Format("{0} (c) {1}", BlogConfig.Copyright, DateTime.Now.Year)), new XElement("ttl", "60"), from post in posts let postLink = Url.AbsoluteAction("Details", "PostDetails", new { Id = RavenIdResolver.Resolve(post.Id), Slug = SlugConverter.TitleToSlug(post.Title) }) select new XElement("item", new XElement("title", post.Title), new XElement("description", post.CompiledContent()), new XElement("link", postLink), new XElement("guid", postLink), new XElement("pubDate", post.PublishAt.ToString("R")) ) ) ) ); return(Xml(rss, responseETagHeader)); }
public async Task <IActionResult> Create([FromBody] FootballTeamModel model) { var teamId = await _teamService.Create(model); Uri getDetailUri = new Uri(Url.AbsoluteAction("Get", "Team", new { id = teamId })); return(Created(getDetailUri, new { id = teamId.ToString("N") })); }
public ContentResult Index() { var listSiteMapIndex = new List <SiteMapIndexItemModel> { new SiteMapIndexItemModel(Url.AbsoluteAction("Main", "SiteMap")) }.ToArray(); var contentResult = new SiteMapIndexGenerator().GenerateContentResult(listSiteMapIndex); return(contentResult); }
public async Task <IActionResult> Create([FromBody] PriceConfigurationModel model) { var configId = await _priceConfigService.Create(model); Uri getDetailUri = new Uri(Url.AbsoluteAction("Get", "Team", new { id = configId })); return(Created(getDetailUri, new { id = configId.ToString("N") })); }
public ActionResult ExternalLogin(string provider, string returnUrl) { switch(provider) { case "facebook": var redirectUrl = Url.AbsoluteAction("FacebookCallback", "Account", new { returnUrl }); return Redirect($"https://www.facebook.com/v3.1/dialog/oauth?client_id={_socialKeys.FacebookAppId}&redirect_uri={redirectUrl}&state={_socialKeys.LocalVerificationToken}"); } return RedirectToAction("Login").WithError(provider); }
public async Task <IActionResult> TraktReturn() { if (Request.Query.ContainsKey("code")) { var traktClient = new TraktClient(_config["TraktConfig:ClientId"], _config["TraktConfig:ClientSecret"]); traktClient.Authentication.RedirectUri = Url.AbsoluteAction("TraktReturn", "Home"); var authResp = await traktClient.Authentication.GetAuthorizationAsync(Request.Query["code"].First()); HttpContext.Session.SetString("TraktKey", authResp.Value.AccessToken); return(RedirectToAction(nameof(Index))); } throw new Exception("Trakt auth failed"); }