27 lines
806 B
C#
27 lines
806 B
C#
using System;
|
|
using System.Web;
|
|
using Microsoft.AspNet.Identity.Owin;
|
|
using Microsoft.Owin;
|
|
using Umbraco.Core;
|
|
using Umbraco.Core.Models.Identity;
|
|
using Umbraco.Core.Security;
|
|
using Umbraco.Web.Security.Identity;
|
|
|
|
namespace Umbraco.Web.Security
|
|
{
|
|
internal static class OwinExtensions
|
|
{
|
|
|
|
/// <summary>
|
|
/// Nasty little hack to get httpcontextbase from an owin context
|
|
/// </summary>
|
|
/// <param name="owinContext"></param>
|
|
/// <returns></returns>
|
|
internal static Attempt<HttpContextBase> TryGetHttpContext(this IOwinContext owinContext)
|
|
{
|
|
var ctx = owinContext.Get<HttpContextBase>(typeof(HttpContextBase).FullName);
|
|
return ctx == null ? Attempt<HttpContextBase>.Fail() : Attempt.Succeed(ctx);
|
|
}
|
|
|
|
}
|
|
} |