Load api keys from database. Create api keys.

This commit is contained in:
Robert Marshall 2021-05-08 09:33:09 +01:00
parent 8d1598ca31
commit 2f38780d2f
2 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,13 @@
using Robware.Auth.API;
using Robware.Data.ApiKeys.State;
namespace Robware.Data.ApiKeys {
public class DatabaseApiKey:ApiKey {
public DatabaseApiKey(ApiKeyState state) {
Name = state.Name;
Key = state.Key;
IssueTimestamp = state.IssueTimestamp;
Enabled = state.Enabled;
}
}
}

View file

@ -0,0 +1,21 @@
using MongoDB.Bson.Serialization.Attributes;
using Robware.Auth.API;
using System;
namespace Robware.Data.ApiKeys.State {
public class ApiKeyState {
public ApiKeyState(ApiKey apiKey) {
Name = apiKey.Name;
IssueTimestamp = apiKey.IssueTimestamp;
Key = apiKey.Key;
Enabled = apiKey.Enabled;
}
[BsonId]
public int Id { get; set; }
public string Name { get; set; }
public DateTime IssueTimestamp { get; set; }
public string Key { get; set; }
public bool Enabled { get; set; }
}
}