mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
moved access token to browser based
This commit is contained in:
@@ -1,73 +1,28 @@
|
||||
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
|
||||
|
||||
public class BrowserStorageManagement
|
||||
public class BrowserStorageManagement : ICanvasTokenManagement
|
||||
{
|
||||
// private string moduleStorageKey = "module storage key";
|
||||
// private string assignmentStorageKey = "assignment storage key";
|
||||
// private string courseIdKey = "course id storage key";
|
||||
private string canvasKey = "canvas key";
|
||||
|
||||
private CoursePlanner planner { get; }
|
||||
private ProtectedLocalStorage storage { get; }
|
||||
private CanvasService canvas { get; }
|
||||
|
||||
public BrowserStorageManagement(
|
||||
CoursePlanner configurationManagement,
|
||||
ProtectedLocalStorage BrowserStorage,
|
||||
CanvasService canvasService
|
||||
)
|
||||
public BrowserStorageManagement(ProtectedLocalStorage BrowserStorage)
|
||||
{
|
||||
planner = configurationManagement;
|
||||
storage = BrowserStorage;
|
||||
canvas = canvasService;
|
||||
}
|
||||
|
||||
// public async Task LoadStoredConfig()
|
||||
// {
|
||||
// // var storedModules = await storage.GetAsync<IEnumerable<CourseModule>>(moduleStorageKey);
|
||||
// // if (storedModules.Success)
|
||||
// // {
|
||||
// // planner.Modules =
|
||||
// // storedModules.Value
|
||||
// // ?? throw new Exception("stored modules was null, it shouldn't have been");
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // Console.WriteLine("no stored modules");
|
||||
// // }
|
||||
public async Task<string?> GetCanvasToken()
|
||||
{
|
||||
var result = await storage.GetAsync<string>(canvasKey);
|
||||
if (!result.Success)
|
||||
return null;
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
// // var storedAssignments = await storage.GetAsync<IEnumerable<CourseModule>>(assignmentStorageKey);
|
||||
// // if (storedAssignments.Success)
|
||||
// // {
|
||||
// // planner.Modules =
|
||||
// // storedAssignments.Value
|
||||
// // ?? throw new Exception("stored assignments are null, it shouldn't have been");
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // Console.WriteLine("no stored assignments");
|
||||
// // }
|
||||
|
||||
// // var storedCourseId = await storage.GetAsync<ulong>(courseIdKey);
|
||||
// // if (storedCourseId.Success)
|
||||
// // {
|
||||
// // // var courses =
|
||||
// // planner.Course = await canvas.GetCourse(storedCourseId.Value);
|
||||
// // planner.Modules = await canvas.GetModules(planner.Course.Id);
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // Console.WriteLine("no stored assignments");
|
||||
// // }
|
||||
// }
|
||||
|
||||
// public async Task Save()
|
||||
// {
|
||||
// // await storage.SetAsync(moduleStorageKey, planner.Modules);
|
||||
// // await storage.SetAsync(assignmentStorageKey, planner.Assignments);
|
||||
|
||||
// // if (planner.Course != null)
|
||||
// // await storage.SetAsync(courseIdKey, planner.Course.Id);
|
||||
// // else
|
||||
// // await storage.DeleteAsync(courseIdKey);
|
||||
// }
|
||||
public async Task SaveCanvasToken(string token)
|
||||
{
|
||||
await storage.SetAsync(canvasKey, token);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user