protected IAuthTokens Init(IServiceBase authService, ref IAuthSession session, Authenticate request) { var requestUri = authService.Request.AbsoluteUri; if (this.CallbackUrl.IsNullOrEmpty()) { this.CallbackUrl = requestUri; } if (session.ReferrerUrl.IsNullOrEmpty()) { session.ReferrerUrl = (request != null ? request.Continue : null) ?? authService.Request.GetHeader("Referer"); } if (session.ReferrerUrl.IsNullOrEmpty() || session.ReferrerUrl.IndexOf("/auth", StringComparison.OrdinalIgnoreCase) >= 0) { session.ReferrerUrl = this.RedirectUrl ?? HttpHandlerFactory.GetBaseUrl() ?? requestUri.Substring(0, requestUri.IndexOf("/", "https://".Length + 1, StringComparison.Ordinal)); } var tokens = session.ProviderOAuthAccess.FirstOrDefault(x => x.Provider == this.Provider); if (tokens == null) { session.ProviderOAuthAccess.Add(tokens = new AuthTokens { Provider = this.Provider }); } return(tokens); }
protected virtual string GetReferrerUrl(IServiceBase authService, IAuthSession session, Authenticate request = null) { if (request == null) { request = authService.Request.Dto as Authenticate; } var referrerUrl = session.ReferrerUrl; if (referrerUrl.IsNullOrEmpty()) { referrerUrl = (request != null ? request.Continue : null) ?? authService.Request.GetHeader("Referer"); } var requestUri = authService.Request.AbsoluteUri; if (referrerUrl.IsNullOrEmpty() || referrerUrl.IndexOf("/auth", StringComparison.OrdinalIgnoreCase) >= 0) { referrerUrl = this.RedirectUrl ?? HttpHandlerFactory.GetBaseUrl() ?? requestUri.Substring(0, requestUri.IndexOf("/", "https://".Length + 1, StringComparison.Ordinal)); } return(referrerUrl); }
public object Get(ResetUserAuth request) { this.Cache.Remove(SessionFeature.GetSessionKey(Request)); Db.DeleteAll <UserAuth>(); Db.DeleteAll <UserAuthDetails>(); var referrer = Request.UrlReferrer != null ? Request.UrlReferrer.AbsoluteUri : HttpHandlerFactory.GetBaseUrl(); return(HttpResult.Redirect(referrer)); }