public async Task <bool> UserExists(string id) { var partitionKey = BackOfficeUserEntity.GeneratePartitionKey(); var rowKey = BackOfficeUserEntity.GenerateRowKey(id); return((await _tableStorage.GetDataAsync(partitionKey, rowKey)) != null); }
public Task ChangePasswordAsync(string id, string newPassword) { var partitionKey = BackOfficeUserEntity.GeneratePartitionKey(); var rowKey = BackOfficeUserEntity.GenerateRowKey(id); return(_tableStorage.ReplaceAsync(partitionKey, rowKey, itm => { itm.SetPassword(newPassword); return itm; })); }
public async Task <IBackOfficeUser> GetAsync(string id) { if (id == null) { return(null); } var partitionKey = BackOfficeUserEntity.GeneratePartitionKey(); var rowKey = BackOfficeUserEntity.GenerateRowKey(id); return(await _tableStorage.GetDataAsync(partitionKey, rowKey)); }
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; }
public async Task <IBackOfficeUser> AuthenticateAsync(string username, string password) { if (username == null || password == null) { return(null); } var partitionKey = BackOfficeUserEntity.GeneratePartitionKey(); var rowKey = BackOfficeUserEntity.GenerateRowKey(username); var entity = await _tableStorage.GetDataAsync(partitionKey, rowKey); if (entity == null) { return(null); } return(entity.CheckPassword(password) ? entity : null); }
public Task SaveAsync(IBackOfficeUser backOfficeUser, string password) { var newUser = BackOfficeUserEntity.Create(backOfficeUser, password); return(_tableStorage.InsertOrReplaceAsync(newUser)); }
public static bool CheckPassword(this BackOfficeUserEntity entity, string password) { var hash = CalcHash(password, entity.Salt); return(entity.Hash == hash); }
public static void SetPassword(this BackOfficeUserEntity entity, string password) { entity.Salt = Guid.NewGuid().ToString(); entity.Hash = CalcHash(password, entity.Salt); }
public async Task <IEnumerable <IBackOfficeUser> > GetAllAsync() { var partitionKey = BackOfficeUserEntity.GeneratePartitionKey(); return(await _tableStorage.GetDataAsync(partitionKey)); }