User Authentication Flow Works

This commit is contained in:
2026-01-25 15:03:17 -06:00
parent 1bf0acdf39
commit e76caa68f1
22 changed files with 275 additions and 248 deletions
+36
View File
@@ -0,0 +1,36 @@
import { Hono } from "hono/tiny";
import { createRoute } from "../../modules/api-utils/createRoute";
import * as msal from "@azure/msal-node";
import { msalClient } from "../../constants";
import { users } from "../../managers/users";
/* /v1/authRedirect */
export default createRoute("get", ["/"], async (c) => {
c.status(200);
console.log("Query", c.req.query());
const tokenRequest: msal.AuthorizationCodeRequest = {
code: c.req.query().code as string,
scopes: ["user.read"],
redirectUri: "http://localhost:3000/v1/auth/redirect",
};
const authResult = await msalClient.acquireTokenByCode(tokenRequest);
await users.authenticate(authResult);
// This closes the window because duh
return c.html(`
<script>
window.close();
</script>
`);
/* return c.json({
status: 200,
message: "Auth Redirect Endpoint",
data: authResult,
successful: true,
}); */
});