Remove MySQL
This commit is contained in:
parent
0d0c077d84
commit
6e412f4f26
9 changed files with 0 additions and 131 deletions
|
@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robware.Auth", "Robware.Aut
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robware.Auth.Tests", "Robware.Auth.Tests\Robware.Auth.Tests.csproj", "{E229DE31-8DBB-4AED-9461-A04C8DE0F074}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robware.Auth.Tests", "Robware.Auth.Tests\Robware.Auth.Tests.csproj", "{E229DE31-8DBB-4AED-9461-A04C8DE0F074}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robware.Data", "Robware.Data\Robware.Data.csproj", "{69989FA2-BEE8-491D-97B9-856D4916D154}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "..\build\_build.csproj", "{19A36DA9-BFBF-4988-B7C7-4808D6B57246}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "..\build\_build.csproj", "{19A36DA9-BFBF-4988-B7C7-4808D6B57246}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robware.Data.MongoDB", "Robware.Data.MongoDB\Robware.Data.MongoDB.csproj", "{574A8F26-06E4-4225-AE82-5824A721DD10}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robware.Data.MongoDB", "Robware.Data.MongoDB\Robware.Data.MongoDB.csproj", "{574A8F26-06E4-4225-AE82-5824A721DD10}"
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Robware.Auth\Robware.Auth.csproj" />
|
<ProjectReference Include="..\Robware.Auth\Robware.Auth.csproj" />
|
||||||
<ProjectReference Include="..\Robware.Data\Robware.Data.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
|
@ -1,43 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Linq;
|
|
||||||
using Dapper;
|
|
||||||
using Robware.Auth.API;
|
|
||||||
using Robware.Data.Users;
|
|
||||||
|
|
||||||
namespace Robware.Data.API {
|
|
||||||
public class ApiKeyRepository : IApiKeys {
|
|
||||||
private readonly IDatabaseProvider _dbProvider;
|
|
||||||
|
|
||||||
public ApiKeyRepository(IDatabaseProvider dbProvider) {
|
|
||||||
_dbProvider = dbProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<ApiKey> Get(string key) {
|
|
||||||
const string query = "SELECT * FROM api_keys WHERE api_key=@key";
|
|
||||||
|
|
||||||
using (var connection = _dbProvider.NewConnection()) {
|
|
||||||
connection.Open();
|
|
||||||
var result = await connection.QueryAsync<ApiKeyState>(query, new {key});
|
|
||||||
|
|
||||||
if (!result.Any())
|
|
||||||
throw new ApiKeyNotFoundException(key);
|
|
||||||
|
|
||||||
var dbKey = result.Single();
|
|
||||||
return new ApiKey {
|
|
||||||
Key = dbKey.Api_Key,
|
|
||||||
Enabled = dbKey.Enabled,
|
|
||||||
IssueTimestamp = dbKey.IssueTimestamp,
|
|
||||||
Name = dbKey.Name
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ApiKeyState {
|
|
||||||
public string Name { get; set; }
|
|
||||||
public DateTime IssueTimestamp { get; set; }
|
|
||||||
public string Api_Key { get; set; }
|
|
||||||
public bool Enabled { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Dapper" Version="2.0.35" />
|
|
||||||
<PackageReference Include="MySqlConnector" Version="0.63.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Robware.Auth\Robware.Auth.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,11 +0,0 @@
|
||||||
using Robware.Auth.Users;
|
|
||||||
using Robware.Data.Users.States;
|
|
||||||
|
|
||||||
namespace Robware.Data.Users {
|
|
||||||
public class DatabaseUser : User {
|
|
||||||
public DatabaseUser(UserState state) {
|
|
||||||
Username = state.User_Email;
|
|
||||||
Password = state.User_Password;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
using System.Data;
|
|
||||||
|
|
||||||
namespace Robware.Data.Users {
|
|
||||||
public interface IDatabaseProvider {
|
|
||||||
IDbConnection NewConnection();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
using System.Data;
|
|
||||||
using MySql.Data.MySqlClient;
|
|
||||||
|
|
||||||
namespace Robware.Data.Users {
|
|
||||||
public class MySQLDatabaseProvider : IDatabaseProvider {
|
|
||||||
private readonly string _connectionString;
|
|
||||||
|
|
||||||
public MySQLDatabaseProvider(string connectionString) => _connectionString = connectionString;
|
|
||||||
|
|
||||||
public IDbConnection NewConnection() => new MySqlConnection(_connectionString);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
namespace Robware.Data.Users.States {
|
|
||||||
public class UserState {
|
|
||||||
public string User_Id { get; set; }
|
|
||||||
public string User_Email { get; set; }
|
|
||||||
public string User_Password { get; set; }
|
|
||||||
public string User_Created { get; set; }
|
|
||||||
public string User_Deleted { get; set; }
|
|
||||||
public string Group_Id { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Dapper;
|
|
||||||
using Robware.Auth.Users;
|
|
||||||
using Robware.Data.Users.States;
|
|
||||||
|
|
||||||
namespace Robware.Data.Users {
|
|
||||||
public class UserRepository : IUsers {
|
|
||||||
private readonly IDatabaseProvider _dbProvider;
|
|
||||||
|
|
||||||
public UserRepository(IDatabaseProvider dbProvider) {
|
|
||||||
_dbProvider = dbProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<User> GetByEmail(string email) {
|
|
||||||
const string query = "SELECT * FROM users WHERE user_email=@email";
|
|
||||||
|
|
||||||
using (var connection = _dbProvider.NewConnection()) {
|
|
||||||
connection.Open();
|
|
||||||
var result = await connection.QueryAsync<UserState>(query, new { email });
|
|
||||||
|
|
||||||
if (!result.Any())
|
|
||||||
throw new UserNotFoundException(email);
|
|
||||||
|
|
||||||
return new DatabaseUser(result.Single());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue