Example #1
0
        private void SignIn(IBackOfficeUser user)
        {
            var authManager = HttpContext.GetOwinContext().Authentication;

            var identity = MakeIdentity(user);

            authManager.SignIn(new AuthenticationProperties {
                IsPersistent = false
            }, identity);
        }
        public Task UpdateAsync(IBackOfficeUser backOfficeUser)
        {
            string partitionKey = BackOfficeUserEntity.GeneratePartitionKey();
            string rowKey       = BackOfficeUserEntity.GenerateRowKey(backOfficeUser.Id);

            return(_tableStorage.MergeAsync(partitionKey, rowKey, entity =>
            {
                entity.Edit(backOfficeUser);
                return entity;
            }));
        }
Example #3
0
        private static ClaimsIdentity MakeIdentity(IBackOfficeUser user)
        {
            var claims = new List <Claim>
            {
                new Claim(ClaimTypes.Name, user.Id),
                new Claim(ClaimTypes.Email, user.Id)
            };


            var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);

            return(identity);
        }
        public static BackOfficeUserEntity Create(IBackOfficeUser src, string password)
        {
            var result = new BackOfficeUserEntity
            {
                PartitionKey = GeneratePartitionKey(),
                RowKey       = GenerateRowKey(src.Id.Trim()),
            };

            result.Edit(src);
            result.SetPassword(password);

            return(result);
        }
Example #5
0
        public static BackOfficeUserEntity Create(IBackOfficeUser src, string password)
        {
            var result = new BackOfficeUserEntity
            {
                PartitionKey = GeneratePartitionKey(),
                RowKey       = GenerateRowKey(src.Id),
                IsAdmin      = src.IsAdmin,
                FullName     = src.FullName
            };

            result.SetPassword(password);

            return(result);
        }
        public static BackOfficeUserEntity Create(IBackOfficeUser src, string password)
        {
            var result = new BackOfficeUserEntity
            {
                PartitionKey = GeneratePartitionKey(),
                RowKey = GenerateRowKey(src.Id),
                IsAdmin = src.IsAdmin,
                FullName = src.FullName

            };

            result.SetPassword(password);

            return result;
        }
Example #7
0
        private async Task SignIn(IBackOfficeUser user)
        {
            var claims = new List <Claim>
            {
                new Claim(ClaimTypes.Name, user.Id),
                new Claim(ClaimTypes.Email, user.Id)
            };

            var userIdentity = new ClaimsIdentity(claims, "Passport");

            var userPrincipal = new ClaimsPrincipal(userIdentity);

            await HttpContext.Authentication.SignInAsync(LykkeAuthHelper.AuthenticationScheme, userPrincipal,
                                                         new AuthenticationProperties
            {
                IsPersistent = false,
                AllowRefresh = false
            });
        }
        public static bool HasAccessToFeature(this IBackOfficeUser src, IBackofficeUserRole[] roles, UserFeatureAccess feature)
        {
            if (src.IsAdmin)
            {
                return(true);
            }

            foreach (var roleId in src.Roles)
            {
                var foundRole = roles.FirstOrDefault(role => role.Id == roleId);
                if (foundRole == null)
                {
                    continue;
                }

                if (foundRole.Features.Any(f => f == feature))
                {
                    return(true);
                }
            }

            return(false);
        }
 public Task SaveAsync(IBackOfficeUser backOfficeUser, string password)
 {
     return(string.IsNullOrEmpty(backOfficeUser.Id)
         ? CreateAsync(backOfficeUser, password)
         : UpdateAsync(backOfficeUser));
 }
        public Task CreateAsync(IBackOfficeUser backOfficeUser, string password)
        {
            var newUser = BackOfficeUserEntity.Create(backOfficeUser, password);

            return(_tableStorage.InsertOrReplaceAsync(newUser));
        }
Example #11
0
 public Task SaveAsync(IBackOfficeUser backOfficeUser, string password)
 {
     var newUser = BackOfficeUserEntity.Create(backOfficeUser, password);
     return _tableStorage.InsertOrReplaceAsync(newUser);
 }
 internal void Edit(IBackOfficeUser src)
 {
     IsAdmin  = src.IsAdmin;
     FullName = src.FullName;
     SetRoles(src.Roles);
 }
Example #13
0
        private void SignIn(IBackOfficeUser user)
        {
            var authManager = HttpContext.GetOwinContext().Authentication;

            var identity = MakeIdentity(user);

            authManager.SignIn(new AuthenticationProperties { IsPersistent = false }, identity);
        }
Example #14
0
        private static ClaimsIdentity MakeIdentity(IBackOfficeUser user)
        {
            var claims = new List<Claim>
            {
                new Claim(ClaimTypes.Name, user.Id),
                new Claim(ClaimTypes.Email, user.Id)
            };


            var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);

            return identity;
        }