public UserAuthenticationOptions(ICoreUserContext userContext, PathString tokenEndpointPath, TimeSpan accessTokenExpireTimeSpan, TimeSpan refreshTokenExpireTimeSpan, bool allowInsecureHttp = true) { UserContext = userContext; TokenEndpointPath = tokenEndpointPath; AccessTokenExpireTimeSpan = accessTokenExpireTimeSpan; RefreshTokenExpireTimeSpan = refreshTokenExpireTimeSpan; AllowInsecureHttp = allowInsecureHttp; PasswordValidator = new Microsoft.AspNet.Identity.PasswordValidator(); }
/// <summary> /// This creates an instance of CoreUserManager /// </summary> /// <param name="userContext">An implementation of the BasicAuthentication.Users.UserContext abstract class. </param> /// <param name="provider">An instance of a Microsoft.AspNet.IdentityIUserTokenProvider < TUser, string > class which is used to provide password reset tokens.</param> /// <example> /// An Microsoft.AspNet.IdentityIUserTokenProvider < TUser string > can be created using a Microsoft.Owin.Security.DataProtection.IDataProtectionProvider as follows: /// <code> /// Microsoft.Owin.Security.DataProtection.IDataProtectionProvider provider; This needs to be created, here for reference. /// var tokenProvider = new Microsoft.AspNet.Identity.Owin.DataProtectorTokenProvider<BasicAuthentication.Users.IdentityUser>(provider.Create("EmailConfirmation")); /// </code> /// </example> public CoreUserManager(ICoreUserContext userContext, IUserTokenProvider <ICoreIdentityUser, string> provider) : base(new UserStore <ICoreIdentityUser>(userContext)) { this.UserContext = userContext; this.UserTokenProvider = provider; this.UserValidator = new UserValidator <ICoreIdentityUser>(this) { AllowOnlyAlphanumericUserNames = false, }; }
public static async Task <ICoreIdentityUser> GetLoggedInUserAsync(ICoreUserContext userContext) { IIdentity userIdentity = null; if (HttpContext.Current != null && HttpContext.Current.User != null) { userIdentity = HttpContext.Current.User.Identity; } if (userIdentity == null) { return(null); } var user = await userContext.FindUserByNameAsync(userIdentity.Name); return(user); }
/// <summary> /// This creates an instance of CoreUserManager /// </summary> /// <param name="userContext">An implementation of the BasicAuthentication.Users.UserContext abstract class. </param> /// <param name="provider">A Microsoft.Owin.Security.DataProtection.IDataProtectionProvider instance used to create a Microsoft.AspNet.IdentityIUserTokenProvider < TUser, string >.</param> /// <example> /// A Microsoft.Owin.Security.DataProtection.IDataProtectionProvider can be created inside an OWIN startup class as follows: /// <code>app.GetDataProtectionProvider();</code> /// </example> public CoreUserManager(ICoreUserContext userContext, IDataProtectionProvider provider) : base(new UserStore <ICoreIdentityUser>(userContext)) { this.UserContext = userContext; //TODO: // token provider and user manager needs to be static i think: // https://stackoverflow.com/questions/25405307/asp-net-identity-2-giving-invalid-token-error var tokenProvider = new DataProtectorTokenProvider <ICoreIdentityUser>(provider.Create("EmailConfirmation", "ResetPassword")) { TokenLifespan = TimeSpan.FromDays(7) }; this.UserTokenProvider = tokenProvider; this.UserValidator = new UserValidator <ICoreIdentityUser>(this) { AllowOnlyAlphanumericUserNames = false, }; }
public static ICoreIdentityUser GetLoggedInUser(ICoreUserContext userContext) { IIdentity userIdentity = null; if (HttpContext.Current != null && HttpContext.Current.User != null) { userIdentity = HttpContext.Current.User.Identity; } if (userIdentity == null) { return(null); } var result = userContext.FindUserByNameAsync(userIdentity.Name); result.Wait(); if (result.Status != TaskStatus.RanToCompletion) { throw new Exception("Enable to complete async task in non-async mode:\n" + result.Status); } return(result.Result); }
public UserStore(ICoreUserContext userContext) { UserContext = userContext; }
public static ICoreIdentityUser GetLoggedInUser(this ApiController controller, ICoreUserContext userContext) { return(GetLoggedInUser(controller.RequestContext, userContext)); }
public static async Task <ICoreIdentityUser> GetLoggedInUserAsync(this ApiController controller, ICoreUserContext userContext) { return(await GetLoggedInUserAsync(controller.RequestContext, userContext)); }
public static ICoreIdentityUser GetLoggedInUser(HttpRequestContext requestContext, ICoreUserContext userContext) { var user = requestContext.Principal.Identity; //var result = CoreAuthenticationEngine.UserManager.FindByNameAsync(user.Name); var result = userContext.FindUserByNameAsync(user.Name); result.Wait(); if (result.Status != TaskStatus.RanToCompletion) { throw new Exception("Enable to complete async task in non-async mode:\n" + result.Status); } return(result.Result); }
public static async Task <ICoreIdentityUser> GetLoggedInUserAsync(HttpRequestContext requestContext, ICoreUserContext userContext) { var user = requestContext.Principal.Identity; var result = await userContext.FindUserByNameAsync(user.Name); return(result); }
protected MakePaymentService(IUnitOfWork unitOfWork, ICoreUserContext userContext) { _unitOfWork = unitOfWork; _userContext = userContext; }
public MobileRechargeService(IUnitOfWork unitOfWork, ICoreUserContext userContext) : base(unitOfWork, userContext) { _unitOfWork = unitOfWork; _userContext = userContext; }
public UserService(IUnitOfWork unitOfWork, ICoreUserContext userContext) { _unitOfWork = unitOfWork; _userContext = userContext; }
public ElectricityService(IUnitOfWork unitOfWork, ICoreUserContext userContext) : base(unitOfWork, userContext) { _unitOfWork = unitOfWork; _userContext = userContext; }