GetLoginUrl() public method

public GetLoginUrl ( ) : string
return string
Exemplo n.º 1
0
        public ActionResult Index()
        {
            var authUrl = oAuthService.GetLoginUrl();

            ViewBag.LoginUrl = authUrl;
            Log.Info("Home Page Visitor. Referrer: {0}, IP Address: {1}. Agent: {2}", Request.UrlReferrer, GetIPAddress(Request), Request.UserAgent);
            return(View());
        }
Exemplo n.º 2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var    req = filterContext.RequestContext.HttpContext.Request;
            var    accessTokenCookie = req.Cookies["BlazeAT"];
            string accessToken       = null;

            if (accessTokenCookie == null)
            {
                var refreshTokenCookie = req.Cookies["BlazeRT"];
                if (refreshTokenCookie != null && !string.IsNullOrEmpty(refreshTokenCookie.Value))
                {
                    log.Info("Attempting to refresh oauth token");
                    try
                    {
                        var tokens = oAuthService.RefreshTokens(refreshTokenCookie.Value);
                        tokens.RefreshToken = refreshTokenCookie.Value;
                        oAuthService.AssignCookies(tokens, filterContext.RequestContext.HttpContext.Response);
                        accessToken = tokens.AccessToken;
                    } catch (Exception ex)
                    {
                        log.ErrorException("Error refreshing oauth token using value: " + refreshTokenCookie.Value, ex);
                        filterContext.Result = new RedirectResult(oAuthService.GetLoginUrl());
                    }
                }
                else
                {
                    if (Required)
                    {
                        filterContext.Result = new RedirectResult(oAuthService.GetLoginUrl());
                    }
                }
            }
            else
            {
                accessToken = accessTokenCookie.Value;
            }

            if (filterContext.ActionParameters.ContainsKey("auth"))
            {
                filterContext.ActionParameters["auth"] = accessToken;
            }
        }