Beispiel #1
0
        public async Task <ClaimsIdentity> GenerateUserIdentityAsync(IlevusUserManager manager, string authenticationType)
        {
            var userIdentity = await manager.CreateIdentityAsync(this, authenticationType);

            // Add custom user claims here
            userIdentity.AddClaim(new Claim(IlevusClaimTypes.UserCulture, this.Culture, ClaimValueTypes.String));

            return(userIdentity);
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing && _userManager != null)
            {
                _userManager.Dispose();
                _userManager = null;
            }

            base.Dispose(disposing);
        }
Beispiel #3
0
        public void MakePayment(HireServiceModel model, IlevusUserManager userManager)
        {
            UserManager = userManager;
            IlevusUser professionalUser = RetrieveUserByService(model.service.Id);

            UserService servicoToHire = professionalUser.Professional.Services.FirstOrDefault(x => x.Id == model.service.Id);

            BuyAService(servicoToHire, model);

            // Verificando se o profissional ja tem conta no stripe. se nao tem se cria.
            AccountPayment accountStripe = CreateORetrieveStripeAccount(professionalUser);

            TransferToProfessional(servicoToHire.Price, accountStripe);
        }
Beispiel #4
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            IlevusUserManager userManager = context.OwinContext.GetUserManager <IlevusUserManager>();
            IlevusUser        user        = await userManager.FindAsync(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", Messages.AuthInvalidUserCredentials);
                return;
            }

            ClaimsIdentity cookiesIdentity = await CreateCookieIdentity(user, userManager);

            context.Request.Context.Authentication.SignIn(cookiesIdentity);

            ClaimsIdentity oAuthIdentity = await CreateOAuthIdentity(user, userManager);

            AuthenticationProperties properties = CreateProperties(user.UserName);
            AuthenticationTicket     ticket     = new AuthenticationTicket(oAuthIdentity, properties);

            context.Validated(ticket);
        }
Beispiel #5
0
        public static async Task <JObject> GenerateLocalAccessTokenResponse(IlevusUser user, IlevusUserManager userManager, IOwinContext context)
        {
            ClaimsIdentity cookiesIdentity = await CreateCookieIdentity(user, userManager);

            context.Request.Context.Authentication.SignIn(cookiesIdentity);

            ClaimsIdentity oAuthIdentity = await CreateOAuthIdentity(user, userManager);

            AuthenticationProperties properties = CreateProperties(user.UserName);
            AuthenticationTicket     ticket     = new AuthenticationTicket(oAuthIdentity, properties);

            var accessToken = Startup.OAuthBearerOpts.AccessTokenFormat.Protect(ticket);

            JObject tokenResponse = new JObject(
                new JProperty("userName", user.UserName),
                new JProperty("access_token", accessToken),
                new JProperty("token_type", "bearer"),
                new JProperty("expires_in", Startup.OAuthAuthzOpts.AccessTokenExpireTimeSpan.TotalSeconds.ToString()),
                new JProperty(".issued", ticket.Properties.IssuedUtc.ToString()),
                new JProperty(".expires", ticket.Properties.ExpiresUtc.ToString())
                );

            return(tokenResponse);
        }
Beispiel #6
0
        protected static async Task <ClaimsIdentity> CreateCookieIdentity(IlevusUser user, IlevusUserManager userManager)
        {
            ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, CookieAuthenticationDefaults.AuthenticationType);

            oAuthIdentity.AddClaims(IlevusPermissionsProvider.GetPermissionClaims(user, oAuthIdentity));

            return(oAuthIdentity);
        }
 public SystemController(IlevusUserManager userManager)
 {
     UserManager = userManager;
 }